Skip to content

Instantly share code, notes, and snippets.

@ephsmith
Created August 1, 2020 14:32
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 ephsmith/82a3aa7d57c2f017d139cd59c03515ff to your computer and use it in GitHub Desktop.
Save ephsmith/82a3aa7d57c2f017d139cd59c03515ff to your computer and use it in GitHub Desktop.
Transpose a 2D Python List
m = [[1,2,3],[4,5,6],[7,8,9]]
m_t = list(map(list,zip(*m)))
# m_t is now -> [[1,4,7], [2,5,8], [3,6,9]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment