Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
To understand why your code doesn't work, run this: items = ['a', '', 'b', '', 'c', '', 'd', '', 'e', ''] print(len(items)) for index, item in enumerate(items): print(index, repr(item), items) if item == '': items.remove('') When you remove an item, all the remaining items slide over one position, into the slot that has already been inspected. That means that they get skipped. ---------- resolution: -> not a bug _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44952> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com