Skip to content

Instantly share code, notes, and snippets.

@yuvadm
Created August 6, 2011 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuvadm/1129328 to your computer and use it in GitHub Desktop.
Save yuvadm/1129328 to your computer and use it in GitHub Desktop.
Transposing a matrix in Python
matrix = [(0,1,2), (0,1,2), (0,1,2)]
transposed = zip(*matrix) # pythonic transpose!
print transposed
# >>> [(0, 0, 0), (1, 1, 1), (2, 2, 2)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment