What is the most efficient way to do this?

Mark McEahern marklists at mceahern.com
Fri Feb 8 14:36:44 EST 2002


[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']





More information about the Python-list mailing list