0

I can't understand why the second time the t_matix is looped over, nothing is printed.

  • In Python 2.x the second print is done correctly.
  • In Python 3.x (at least 3.6.3) that second print is not done.

What is happening with that t_matrix variable between the 2 loops?

matrix=[(1,2,3),(4,5,6),(7,8,9),(10,11,12)]
for row in matrix:
    print(row)
print("\n")
t_matrix = zip(*matrix)
for row in t_matrix:        # first print, printed ok
    print(row)
print('-' * 80)
for row in t_matrix:        # Second print, nothing shown
    print(row)

0 Answers0