I am trying to create a matrix transpose function for python but I can\'t seem to make it work. Say I have
theArray = [[\'a\',\'b\',\'c\'],[\'d\',\'e\',\'f\
The "best" answer has already been submitted, but I thought I would add that you can use nested list comprehensions, as seen in the Python Tutorial.
Here is how you could get a transposed array:
def matrixTranspose( matrix ):
if not matrix: return []
return [ [ row[ i ] for row in matrix ] for i in range( len( matrix[ 0 ] ) ) ]