Welcome to the Genome Toolbox! I am glad you navigated to the blog and hope you find the contents useful and insightful for your genomic needs. If you find any of the entries particularly helpful, be sure to click the +1 button on the bottom of the post and share with your colleagues. Your input is encouraged, so if you have comments or are aware of more efficient tools not included in a post, I would love to hear from you. Enjoy your time browsing through the Toolbox.

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