On 6/11/2009 11:54 AM Brendan said...
Can someone please explain what is happening in the output below?

you delete e[2] before displaying it.

The
number 3 never gets printed. Does Python make a copy of a list before
it iterates through it?:

No.

Mods to a list while passing it is generally not a good idea. Sometimes passing the list backwards works.

Emile


e = range(1,5)
for i in e:
        print i
        if i == 2 :
                e.remove(i)


1
2
4
e
[1, 3, 4]

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to