Python Forum
putting 2 lists items side by side
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
putting 2 lists items side by side
#1
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.
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  putting API results into a dataframe in Python tturner2304 1 930 Aug-01-2025, 11:19 PM
Last Post: Pedroski55
  How to horizontally align and display images side-by-side in an email using Python? shantanu97 0 2,796 Feb-22-2023, 11:41 PM
Last Post: shantanu97
  Get the Client-Side TLS ? JohnnyCoffee 1 2,360 Nov-30-2021, 10:49 PM
Last Post: Larz60+
  List / arrays putting in sentence Kurta 3 4,104 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  4D array with only elements on one side of the diagonal schniefen 0 2,555 Dec-24-2020, 11:32 AM
Last Post: schniefen
  Split dict of lists into smaller dicts of lists. pcs3rd 3 4,079 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  NumPy Side Effects - HELP UNDERSTANDING lasek723 3 6,208 Sep-17-2020, 06:56 AM
Last Post: lasek723
  Comparing items from 2 lists of dictionaries illwill 7 5,571 Sep-14-2020, 10:46 PM
Last Post: bowlofred
  Explanation of the left side of this statement please rascalsailor 3 4,038 Sep-09-2020, 02:02 PM
Last Post: rascalsailor
  How to put the items of one list in new generated lists Bobbear 1 2,596 Jun-12-2020, 06:08 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020