📜  python list .remove() in for 循环中断 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:08.122000             🧑  作者: Mango

代码示例1
elements = ['el1', 'el2', 'el3', 'el4', 'el5']
for el in elements[:]: #[:] shallow-copies the list
    if el.lower() in ['el2', 'el3', 'el4']:
        elements.remove(el)
// elements -> ['el1', 'el5']