Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
This is not a language bug, it is a bug in your code: you are modifying the list as you iterate over it. There are lots of ways to do that task correctly, perhaps the easiest is with a filter: str_list = list(filter(bool, str_list)) or a list comprehension: str_list = [s for s in str_list if s] or by iterating over a copy of the list: for item in str_list[:]: # use slice syntax to make a copy ... ---------- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43150> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com