Open this example in the interactive library
Source code
matrix = [[1, 2, 3], [4, 5, 6]]
print(list(zip(*matrix)))Sample output
[(1, 4), (2, 5), (3, 6)]

Transpose a matrix. A self-contained example using the Python standard library.
Open this example in the interactive library
matrix = [[1, 2, 3], [4, 5, 6]]
print(list(zip(*matrix)))[(1, 4), (2, 5), (3, 6)]