How to print elements within each row of a nested list of tuples by index in Python

1 Answer

0 votes
# Create a nested list of tuples
data = [
    [(1, 2), (3, 4)],
    [(5, 6), (7, 8)],
    [(9, 10), (11, 12)]
]

for i, row in enumerate(data):
    for j, tup in enumerate(row):
        print(f"Row {i}, Col {j}: {tup}")




'''
run:

Row 0, Col 0: (1, 2)
Row 0, Col 1: (3, 4)
Row 1, Col 0: (5, 6)
Row 1, Col 1: (7, 8)
Row 2, Col 0: (9, 10)
Row 2, Col 1: (11, 12)

'''

 



answered Feb 9 by avibootz

Related questions

...