Petri Lehtinen <pe...@digip.org> added the comment: This happens because you modify the list while iterating over it, which makes the loop not work as you expect. Essentially, when you remove the item that's currently being pointed to, the loop skips over the next item.
An idiomatic way to remove items from a list is to use a list comprehension to create a new list without the unwanted items: item_list = ["apple", "bananna", "blueberry", "coconut"] new_list = [item for item in item_list if not item.startswith('b')] ---------- nosy: +petri.lehtinen resolution: -> invalid stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15214> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com