list.remove(): bug ??

Mathieu Malaterre Mathieu.Malaterre at creatis.insa-lyon.fr
Wed Jun 11 19:52:52 CEST 2003


Hi all,

here is a very simple script:

liste = ['foo1' , 'foo2', 'foo3', 'foo4', 'foo5' ]
for i in liste:
   if i == 'foo2':
     liste.remove( i )
   else:
     print i


But the result is:

foo1
foo4
foo5

How should I do to still print 'foo3' ??

thanks a lot,
mathieu





More information about the Python-list mailing list