for i in list - change a list inside a for loop?
km-news1 at onlinehome.de
Sat Mar 1 20:51:24 CET 2003
> Better read about it in the Language Reference,
for i in x:
Hm, the ref says:
The expression list is evaluated once
If this was true, shouldn't the example stop after 10 loops?
But this gives a nice endless loop and a growing and growing x ....
> Eh.. no need to search for the element in the list.
> This is painfully slow.
My example was a simplification. In real i need re and something else so i
must iterate over all elements.
I think i make a new list similarly to that example, that Anton gave. This
would be a clean solution, i think.
Gruß - regards Klaus :-)
More information about the Python-list