How we can iterate through a Python list of tuples?

Easiest way is to employ two nested for loops. Outer loop fetches each tuple and inner loop traverses each item from the tuple. Inner print() function end=’ ‘ to print all items in a tuple in one line. Another print() introduces new line after each tuple.


L=[(1,2,3), (4,5,6), (7,8,9,10)]
for x in L:
  for y in x:
    print(y, end=' ')


1 2 3

4 5 6

7 8 9 10

Updated on: 20-Feb-2020

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started