best way to do this

Diez B. Roggisch deets at nospam.web.de
Tue Dec 2 09:22:43 EST 2008


TP wrote:

> Hi everybody,
> 
>>>> c=[(5,3), (6,8)]
> 
> From c, I want to obtain a list with 5,3,6, and 8, in any order.
> I do this:
> 
>>>> [i for (i,j) in c] + [ j for (i,j) in c]
> [5, 6, 3, 8]
> 
> Is there a quicker way to do this?

dunno if it's faster, but less cluttered:

list(sum(c, ()))

Diez




More information about the Python-list mailing list