py_ok <1979239...@qq.com> added the comment:

Yes,I remember that my error in Java,like you say it`s skiped

------------------&nbsp;原始邮件&nbsp;------------------
发件人: "Python tracker"<rep...@bugs.python.org&gt;; 
发送时间: 2021年8月19日(星期四) 中午12:53
收件人: "海"<1979239...@qq.com&gt;; 
主题: [issue44952] list need to filter again because the continue empty str value?

Steven D'Aprano <steve+pyt...@pearwood.info&gt; 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):
&nbsp;&nbsp;&nbsp; print(index, repr(item), items)
&nbsp;&nbsp;&nbsp; if item == '':
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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:&nbsp; -&gt; not a bug

_______________________________________
Python tracker <rep...@bugs.python.org&gt;
<" rel="noopener" target="_blank">https://bugs.python.org/issue44952&gt;;
_______________________________________

----------

_______________________________________
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

Reply via email to