Deleting from a list

Brad Bollenbach bbollenbach at home.com
Tue Jan 1 22:07:13 EST 2002


<bvdpoel at uniserve.com> wrote in message
news:3C326CF0.A28B9FC7 at uniserve.com...
>
> Does python have a notion as to where the current item in a list is?
[snip examples attempts at removing an item from a list]

You could do, simply:

foo = [1, 2, 3, 4]

for i in range(foo):
    if foo[i] == 3:
        del foo[i]

foo would then contain [1, 2, 4]


HTH,

Brad





More information about the Python-list mailing list