这是一个 post 讨论不更改正在迭代的容器的原因,即使可以。
使用while循环并在完成后中断如何?
my_list = [1,2] while True: my_list.append(3) if #(check if out of range): break