This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients py_ok, steven.daprano
Date 2021-08-19.04:53:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629348809.81.0.600587264024.issue44952@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-08-19 04:53:29steven.dapranosetrecipients: + steven.daprano, py_ok
2021-08-19 04:53:29steven.dapranosetmessageid: <1629348809.81.0.600587264024.issue44952@roundup.psfhosted.org>
2021-08-19 04:53:29steven.dapranolinkissue44952 messages
2021-08-19 04:53:29steven.dapranocreate