Python Forum

Full Version: putting 2 lists items side by side
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi guys,

can someone advise a syntax for writing items from the list side by side in the output.
For example: Name of groceries and their price and total of the price in the end.

Regards.
you can do this with f-string, using padding
x = 1234
y = 785
print(f"Header1        Header2")
print(f"{x:<15}{y:<15}")
results:
Output:
Header1 Header2 1234 785