yet another list comprehension question

Ross ross.jett at gmail.com
Sat May 2 22:23:38 EDT 2009


On May 2, 7:21 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Sat, May 2, 2009 at 7:13 PM, Ross <ross.j... at gmail.com> wrote:
> > I'm trying to set up a simple filter using a list comprehension. If I
> > have a list of tuples, a = [(1,2), (3,4), (5,None), (6,7), (8, None)]
> > and I wanted to filter out all tuples containing None, I would like to
> > get the new list b = [(1,2), (3,4),(6,7)].
>
> b = [tup for tup in a if None not in tup]
>
> Cheers,
> Chris
> --http://blog.rebertia.com

Thanks I feel retarded sometimes.



More information about the Python-list mailing list