Transpose of a matrix (nested list) in python

row1 = [13,25,73]
row2 = [54,95,36]
row3 = [27,98,19]

matrix = [row1, row2, row3]
trmatrix = [[row[0] for row in matrix],[row[1] for row in matrix],  [row[2] for row in matrix]]
print'Transpose of a matrix',trmatrix

source: http://stackoverflow.com

No comments: