您正在修改要遍历的列表。如果这样做,列表的大小将缩小,因此最终
lst[i]将指向列表的边界之外。
>>> lst = [1,2,3]>>> lst[2]3>>> lst.remove(1)>>> lst[1]3>>> lst[2]Traceback (most recent call last): File "<stdin>", line 1, in <module>IndexError: list index out of range
构造新列表更安全:
return [item for item in lst if item[0]!=1 and item[1]!=1]


![(Python)列表索引超出范围-迭代[重复] (Python)列表索引超出范围-迭代[重复]](http://www.mshxw.com/aiimages/31/646573.png)
