List transpose method

Gustavo Niemeyer niemeyer at conectiva.com
Thu Nov 1 17:51:27 EST 2001


> Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru
> tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can
> only come up with an ugly multiliner.

>>> zip((1,2),(3,4),(5,6))
[(1, 3, 5), (2, 4, 6)]

Best regards!

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20011101/7d81fd91/attachment.sig>


More information about the Python-list mailing list