What is the most efficient way to do this?

MDK mdk at mdk.com
Fri Feb 8 21:13:07 CET 2002


"Mark McEahern" <marklists at mceahern.com> wrote in message
news:mailman.1013197035.25987.python-list at python.org...
> [MDK]
> > What is the most efficient way to remove empty items from this list?
> >
> > ['', '1', '2', '3', '', '456', '789', 'wow']
>
> Try filter:
>
> >>> l = ['', '1', '2', '3', '', '456', '789', 'wow']
> >>> filter(None, l)
> ['1', '2', '3', '456', '789', 'wow']
>

Very nice.  Thanks!





More information about the Python-list mailing list