Transpose of a matrix - Coder's point

Saturday, June 1, 2019

Transpose of a matrix

 
X = [[1,2], [4,5], [7,8]] Result = [[0,0,0], [0,0,0]] # iterate through rows for i in range(len(X)): for j in range(len(X[0])): Result[j][i] = X[i][j] for r in Result: print(r)

  OUTPUT :  
  [1,4,7]  
  [2,5,8]  

No comments:

Post a Comment