Chris Angelico wrote:
if you 'break' immediately after a mutation, that isn't continuing to iterate. Even though you're inside the loop, there's no further action taken to process the loop, and no problem.
Yes, but you're also not calling next() again, so no exception would be triggered. My point is that I don't see a justification for treating the last next() call (the one that notices you've reached the end and raises StopIteration) any differently from the others. It seems like either a bug or a misfeature to me. -- Greg -- https://mail.python.org/mailman/listinfo/python-list