transpose a matrix using list comprehension

MT = [[0,0,0], [0,0,0], [0,0,0]]
for ir in range(3):
    for ic in range(3):
        MT[ic][ir] = M[ir][ic]

Here is what the above code is Doing:
1. It’s creating a new matrix, MT, that is the transpose of M.
2. It’s looping through the rows and columns of M.
3. It’s setting the value of MT[ic][ir] to the value of M[ir][ic].

The result is that MT is the transpose of M.