-1

To transpose the matrix, my code is like this:

def transpose(matrix):

temp_Matrix = matrix[:][:]

for i in range(len(matrix)):

    for j in range(len(matrix[0]):

        temp_Matrix[i][j]=matrix[j][i]

return temp_Matrix

why this code does not work for the non-square matrix?

ccccccc
  • 21

1 Answers1

0

I can't make a comment yet, but here is a post asking about a transpose of a matrix with so many different variations. Take a look:

Transpose in Python

Renee
  • 90
  • 2
  • 10