[New-bugs-announce] [issue43150] Last empty string not removed in a list

Kumar Makala report at bugs.python.org
Sat Feb 6 21:16:14 EST 2021


New submission from Kumar Makala <kumar.ms400 at gmail.com>:

# Last empty string not removed from the list


str_list = ["Emma", "Jon", "", "Kelly","Eric", "", "","KXN",""]
for item in str_list:
    if len(item) == 0:
        str_list.remove(item)
print(len(str_list[-1]))

#Output
['Emma', 'Jon', 'Kelly', 'Eric', 'KXN', '']

----------
messages: 386571
nosy: kumarmakala
priority: normal
severity: normal
status: open
title: Last empty string not removed in a list
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43150>
_______________________________________


More information about the New-bugs-announce mailing list