Skip to content Skip to sidebar Skip to footer

How To Print Each Element Of A List Of Lists In Python Using The Specific Elements

I am trying to print a list of lists in python using for loops. I am having issues doing so. Ive tried a couple of approaches. Here is what I have: for r in range(len(priceChar

Solution 1:

Easiest to use for-each loops:

for l in priceChart:
    for c in l:
        print(c, end= " ")
    print()    

If you have to use indexes:

for r in range(len(priceChart)):  # no '- 1' here, range(x) loops from 0 to x-1for c in range(len(priceChart[r])):  # use 'r', not 0print(priceChart[r][c], end= " ")
    print()  

Post a Comment for "How To Print Each Element Of A List Of Lists In Python Using The Specific Elements"