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

Paul Rubin http
Wed Jan 30 04:36:27 EST 2008


Santiago  Romero <sromero at gmail.com> writes:
>  In  a = [1, 2, 3, 3, 3, 4, 3, 3, 2, 3], the filter solution will
> efectively remove all items with value == 3 while li.remove(3) will
> only remove the first ocurrence.

Hmm, interesting, I didn't realize that (shoulda checked the docs).
Thanks!



More information about the Python-list mailing list