0

I cannot see the problem in my matrix transpose function, it's propably very trivial. In the first part I am creating a matrix with zeros, the size of A:

A = [[1, 2], [3, 4], [5, 6]]
line = []
A_T = []
for e in A:
    linha.append(0)
for e in A[0]:
    A_T.append(linha)

The output seems to be identical to [[0,0,0], [0,0,0]], but the code only works if I define this 0-matrix manually, otherwise the output is [[2, 4, 6],[2, 4, 6]].

the second part of the code:

for e in range(len(A_T)):
    for i in range(len(A_T[0])):
        A_T[e][i] = A[i][e]

any ideas?

0 Answers0