p008_remove_elements_from_list

代码:

def remove_elements_from_list(i,j):
    for itam in j:
        i.remove(itam)
    return i




lista=[3,5,7,9,11,13]
listb=[7,11]
print(f"from {lista} remove {listb},result: " ,remove_elements_from_list(lista,listb))

效果:

from [3, 5, 7, 9, 11, 13] remove [7, 11],result:  [3, 5, 9, 13]

总结:

列表的功能需要掌握:for itam in j:

                                         i.remove(itam)

原文地址:https://www.cnblogs.com/scholarly/p/15422467.html