I have to write a function transpose() that transposes both square matrices(n rows x n columns) and rectangular (mxn) matrices using tuples
def transpose(matrix):
rows = len(matrix)
columns = len(matrix[0])
matrix_T = []
for j in range(columns):
row = []
for i in range(rows):
row.append(matrix[i][j])
matrix_T.append(row)
return matrix_T
this is the code i found for transposing matrices, however, it does not work for my task, as the expected result is tuple and the actual result is, i assume, list i'd be really thankful if there's someone who could help me adapt the code to fit my needs enter image description here