Quantum Computing, Qiskit, Linear Algebra, Mathematics, Python.
elements from the original matrix for i in range(rows): for j in range(columns): transposed[j][i] = a[i][j] return transposed A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] A_transposed = transpose(A) print(A_transposed) # Output: [[1, 4, 7], # [2, 5, 8], # [3, 6, 9]] [[1, 4, 7], [2, 5, 8], [3, 6, 9]]