list traversal and remove
digisatori at gmail.com
digisatori at gmail.com
Thu Jan 31 02:49:46 EST 2008
More information about the Python-list mailing list
Thu Jan 31 02:49:46 EST 2008
- Previous message (by thread): Updating documents in PyLucene
- Next message (by thread): list traversal and remove
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I supposed the below code will print seven 2 and generate the list li
without 2.
Strangely it only print four 2. If you change the number of 2 in the
list, the results are all beyond expectation.
I know the other way to achieve the expected goal, but why this is
happening? Could somebody enlight me?
li= [2,2,2,2,2,2,2,3,4,5,6,7,8,9]
for x in li:
if x == 2:
print x
li.remove(x)
- Previous message (by thread): Updating documents in PyLucene
- Next message (by thread): list traversal and remove
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list