Message399887
Yes,I remember that my error in Java,like you say it`s skiped
------------------ 原始邮件 ------------------
发件人: "Python tracker"<report@bugs.python.org>;
发送时间: 2021年8月19日(星期四) 中午12:53
收件人: "海"<1979239641@qq.com>;
主题: [issue44952] list need to filter again because the continue empty str value?
Steven D'Aprano <steve+python@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 <report@bugs.python.org>
<" rel="noopener" target="_blank">https://bugs.python.org/issue44952>;
_______________________________________ |
|
Date |
User |
Action |
Args |
2021-08-19 04:57:47 | py_ok | set | recipients:
+ py_ok, steven.daprano |
2021-08-19 04:57:47 | py_ok | link | issue44952 messages |
2021-08-19 04:57:47 | py_ok | create | |
|