Removal of element from list while traversing causes the next element to be skipped

Arnaud Delobelle arnodel at
Wed Jan 30 14:22:45 CET 2008

On Jan 30, 11:57 am, Arnaud Delobelle <arno... at> wrote:

> n = len(a)
> for i, x in enumerate(a):
>     if x == 99: del a[i-n]

Oops. That can't work.  Don't know what I was thinking here.  I
probably did had one mental refactoring too many...


More information about the Python-list mailing list