list IndexError

Egor Bolonev ebolonev at mail.ru
Wed Dec 22 16:27:52 EST 2004


On Thu, 23 Dec 2004 06:56:02 +1030, Ishwor <ishwor.gurung at gmail.com> wrote:

>>>> l
> ['a', 'b', 'c', 'd', 'e']
>>>> for x in l[:]:
>        if x == 'd':
>                l.remove('d');
>
>>>> l
> ['a', 'b', 'c', 'e']
> This code is so clean and looks very healthy.  Python will live a
> long way because its a cute language.

imho the code is very unhealthy, i would write
l = ['a', 'b', 'c', 'd', 'e']
l.remove('d')
print l

btw what are you using ';' for



More information about the Python-list mailing list