iterate over list while changing it
Aahz
aahz at pythoncraft.com
Wed Sep 30 19:01:18 EDT 2009
In article <mailman.430.1253826262.2807.python-list at python.org>,
Terry Reedy <tjreedy at udel.edu> 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 pythoncraft.com) <*> http://www.pythoncraft.com/
"....Normal is what cuts off your sixth finger and your tail..." --Siobhan
More information about the Python-list
mailing list