removing list elements while traversing the list has unintended effect

前端 未结 0 1779
死守一世寂寞
死守一世寂寞 2021-01-16 11:39

Here is the simple example

>>> list=[(1,2),(3,4),(5,6)]
>>> for i in list:
...     print(i)
...     list.remove(i)
...
(1, 2)
(5, 6)
>>         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题