[Tutor] creating dictionary from a list
Brian van den Broek
brian.van.den.broek at gmail.com
Sat Apr 13 10:51:59 CEST 2013
On 12 Apr 2013 21:25, "Steven D'Aprano" <steve at pearwood.info> wrote:
> Also, you might find it easier to process the list if you strip out empty
items. There are two simple ways to do it:
>
>
> lst = [x for x in list if x != '']
> # or
> lst = filter(None, lst)
Hi all,
For the first, I would use
lst = [x for x in list if x]
instead.
Best,
Brian vdB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130413/8266449c/attachment.html>
More information about the Tutor
mailing list