Alter list items within loop
Emile van Sebille
emile at fenx.com
Thu Jun 11 21:23:16 CEST 2009
On 6/11/2009 11:54 AM Brendan said...
> Can someone please explain what is happening in the output below?
you delete e before displaying it.
> number 3 never gets printed. Does Python make a copy of a list before
> it iterates through it?:
Mods to a list while passing it is generally not a good idea. Sometimes
passing the list backwards works.
>>>> e = range(1,5)
>>>> for i in e:
> print i
> if i == 2 :
> [1, 3, 4]
More information about the Python-list