Python Forum
Print Nested List Line by Line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print Nested List Line by Line
#6
I see you already corrected it but anyways - read https://python-forum.io/Thread-Basic-Nev...n-sequence
by the way, avoid using cryptic one-letter variable names. There are limited number of cases when it's fine to use such variable names,
but in this case something like:
for drive, space in list_mounts:
    print("Drive: {}, Used Space: {}".format(drive, space))
makes your code much readable
in python 3.6+ you can even take advantage of new f-strings
for drive, space in list_mounts:
    print(f"Drive: {drive}, Used Space: {space}")
finally, you can also use
for drive in list_mounts:
    print("Drive: {}, Used Space: {}".format(*drive))
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Print Nested List Line by Line - by anelliaf - May-23-2018, 06:19 PM
RE: Print Nested List Line by Line - by ThiefOfTime - May-23-2018, 06:37 PM
RE: Print Nested List Line by Line - by anelliaf - May-23-2018, 06:38 PM
RE: Print Nested List Line by Line - by ThiefOfTime - May-23-2018, 06:41 PM
RE: Print Nested List Line by Line - by anelliaf - May-23-2018, 06:44 PM
RE: Print Nested List Line by Line - by buran - May-23-2018, 06:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing the code line number arbiel 5 358 5 hours ago
Last Post: Gribouillis
  How to add multi-line comment section? Winfried 3 490 Jun-04-2024, 07:24 AM
Last Post: Gribouillis
Information Is it possible to multi line a Basic Function Construct line statement? If so how? BrandonKastning 7 523 May-23-2024, 03:02 PM
Last Post: deanhystad
  Line graph with two superimposed lines sawtooth500 4 535 Apr-02-2024, 08:56 PM
Last Post: sawtooth500
  break print_format lengthy line akbarza 4 548 Mar-13-2024, 08:35 AM
Last Post: akbarza
  Reading and storing a line of output from pexpect child eagerissac 1 4,552 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  coma separator is printed on a new line for some reason tester_V 4 671 Feb-02-2024, 06:06 PM
Last Post: tester_V
  problem with spliting line in print akbarza 3 553 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Unable to understand the meaning of the line of code. jahuja73 0 452 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  Receive Input on Same Line? johnywhy 8 1,082 Jan-16-2024, 03:45 AM
Last Post: johnywhy

Forum Jump:

User Panel Messages

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