[Tutor] Iterating through a list of strings
Steven D'Aprano
steve at pearwood.info
Mon May 3 12:21:37 CEST 2010
On Mon, 3 May 2010 05:35:52 pm Andre Engels wrote:
> Don't change the list that you are iterating over. As you have found,
> it leads to (to most) unexpected results.
Or if you absolutely have to change the list in place, iterate over it
*backwards* (starting at the end, and moving towards the beginning), so
that the changes only happen in the part of the list you've already
seen.
--
Steven D'Aprano
More information about the Tutor
mailing list