Pages

Thursday, May 30, 2013

Transpose List of Lists in Python

Today in Python I wanted to be able to transpose a list of lists that I created. So, for example, I wanted to be able to transpose the list

l=[[1,2,3],[4,5,6],[7,8,9]]

to this

t=[[1,4,7],[2,5,8],[3,6,9]]

I found an easy command to do this, where l is the list above and t is the transposed list.

No comments:

Post a Comment