Peter Otten wrote: > If the list is huge you can also delete in reverse order: > > for i in reversed(len(_list)):
Make that reversed(range(len(_list))). > if discard(_list[i]): > del _list[i] Example: >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i, item in enumerate(items): ... if item in "bcd": ... del items[i] ... >>> items ['a', 'c', 'e'] >>> items = ['a', 'b', 'c', 'd', 'e'] >>> for i in reversed(range(len(items))): ... if items[i] in "bcd": ... del items[i] ... >>> items ['a', 'e'] -- https://mail.python.org/mailman/listinfo/python-list