Transposing a matrix means swapping its columns with its rows.

For example, with a matrix of

1 2 3
4 5 6
7 8 9

we turn it into

1 4 7
2 5 8
3 6 9

In Python, one way to do this is to use zip with splat operator:

matrix = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]
 
transposed = list(zip(*matrix))
# [
#  [1, 4, 7],
#  [2, 5, 8],
#  [3, 6, 9]
# ]