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

Arnaud Delobelle arnodel at googlemail.com
Wed Jan 30 08:22:45 EST 2008


On Jan 30, 11:57 am, Arnaud Delobelle <arno... at googlemail.com> 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...

--
Arnaud



More information about the Python-list mailing list