On Jul 8, 2009, at 10:54 AM, ma wrote:

filter(lambda x: x, your_list)

On Wed, Jul 8, 2009 at 10:44 AM, Daniel Austria <futureb...@gmx.at> wrote:
Hi python - hackers,

just one question. How can i remove all 0 values in a list? Sure - i
can loop over it, but that s not a neat style.  list.remove() will
only remove the first occurence. Doing that while no exception is
raised is also uncool, right?

Some suggestions?



L = [0, 0, 0, 1, 1, 1, 0]
M = [x for x in L if x !=0]


Charles Yeomans
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to