iterate over list while changing it

Aahz aahz at
Thu Oct 1 01:01:18 CEST 2009

In article <mailman.430.1253826262.2807.python-list at>,
Terry Reedy  <tjreedy at> wrote:
>Torsten Mohr wrote:
>> a = [1, 2, 3, 4, 5, 6]
>> for i, x in enumerate(a):
>If you change a list while iterating over, start at the tail.

This only applies if you add/remove elements; simply updating elements
does not require starting at the tail.
Aahz (aahz at           <*>

"....Normal is what cuts off your sixth finger and your tail..."  --Siobhan

More information about the Python-list mailing list