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
  How to horizontally align and display images side-by-side in an email using Python? shantanu97 0 997 Feb-22-2023, 11:41 PM
Last Post: shantanu97
  Get the Client-Side TLS ? JohnnyCoffee 1 1,346 Nov-30-2021, 10:49 PM
Last Post: Larz60+
  List / arrays putting in sentence Kurta 3 2,562 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  4D array with only elements on one side of the diagonal schniefen 0 1,683 Dec-24-2020, 11:32 AM
Last Post: schniefen
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,367 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  NumPy Side Effects - HELP UNDERSTANDING lasek723 3 3,468 Sep-17-2020, 06:56 AM
Last Post: lasek723
  Comparing items from 2 lists of dictionaries illwill 7 2,747 Sep-14-2020, 10:46 PM
Last Post: bowlofred
  Explanation of the left side of this statement please rascalsailor 3 2,493 Sep-09-2020, 02:02 PM
Last Post: rascalsailor
  How to put the items of one list in new generated lists Bobbear 1 1,644 Jun-12-2020, 06:08 AM
Last Post: buran
  Compare Two Lists and Replace Items In a List by Index nagymusic 2 2,876 May-10-2020, 05:28 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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