yet another list comprehension question

David Robinow drobinow at gmail.com
Mon May 4 14:15:47 CEST 2009


On Mon, May 4, 2009 at 2:33 AM, namekuseijin
<namekuseijin.nospam at gmail.com> wrote:
>>>> ls = [(1,2), (3,4), (5, None), (6,7), (8, None)]
>>>> [(x,y) for (x,y) in ls if y]
> [(1, 2), (3, 4), (6, 7)]

Nope. That filters out 0 as well as None. Not what the OP asked for.



More information about the Python-list mailing list