Removal of element from list while traversing causes the next element to be skipped

Santiago Romero sromero at gmail.com
Wed Jan 30 02:01:18 EST 2008


> how about
>
> >>> li = [1,2,3,4,5]
> >>> filter(lambda x: x != 3, li)
> [1, 2, 4, 5]

 I haven't measured it, but this should be the fast solution in all
the thread ...




More information about the Python-list mailing list