how to break a for loop?

bonono at gmail.com bonono at gmail.com
Mon Feb 20 21:12:15 EST 2006


Gregory Petrosyan wrote:
>I need to remove zeros from
> the begining of list, but I can't :-(.

I believe the following is almost a direct translation of the above
sentence.

import itertools as it
a=[0,0,0,1,0]
a[:]=it.dropwhile(lambda x: x is 0, a)




More information about the Python-list mailing list