On Sat, 15 Jan 2005 15:27:08 -0500, skull <[EMAIL PROTECTED]> wrote:

lst = [1, 2, 3]
for i in lst:
    print i
    if i == 2:
       lst.remove(i)

the result is:

1
2

As others have suggested, you can use a copy of the list.
Alternatively and depending on what you're trying to accomplish (how complicated it is), lst = [i for i in lst if i!=2] might look better.



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

Reply via email to