[docs] [issue16225] list.remove in for loop
report at bugs.python.org
Sun Oct 14 20:31:14 CEST 2012
Georg Brandl added the comment:
Well, I guess Serhiy meant "neither increase nor decrease".
In the end, the exact behavior will never be clear if you don't state explicitly how it's implemented: a counter that starts at 0 and is increased on __next__ until it's equal to len(list) (as checked at every iteration step). But in general the advice should be: if you want to insert or remove elements during iteration, iterate over a copy.
Python tracker <report at bugs.python.org>
More information about the docs