how to break a for loop?

Scott David Daniels scott.daniels at acm.org
Mon Feb 20 20:38:02 EST 2006


Gregory Petrosyan wrote:
> Hello!
> It's 1:56 o'clock in St.-Petersburg now, and I am still coding... maybe
> that's why I encountered stupid problem: I need to remove zeros from
> the begining of list, but I can't :-(. I use
> 
>         for i,coef in enumerate(coefs):
>             if coef == 0:
>                 del coefs[i]
>             else:
>                 break
     for index, coef in enumerate(coefs):
         if coef:
             if index:
                 del coefs[: index]
             break

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list