best way to do this

alex23 wuwei23 at gmail.com
Wed Dec 3 00:28:04 EST 2008


On Dec 3, 1:38 pm, thor <yaksav... at gmail.com> wrote:
> >>> c = [(5, 3), (6, 8)]
> >>> [x for t in zip(*c) for x in t]
> [5, 6, 3, 8]

The zip here is superfluous.

>>> c = [(5, 3), (6, 8)]
>>> zip(*c)
[(5, 6), (3, 8)]

Unless you're -only- using it to ensure your result is the same order
as the OP...but he also stressed that order was unimportant.

Leaving out the zip call gives you Arnaud's solution, which seems the
clearest.



More information about the Python-list mailing list