python remove all items from list that are in another code example
Example 1: delete element of a list from another list python
l1 = ["a", "b", "c", "d", "e", "f"]
l2 = ["b", "c", "e"]
l1 = [elt for elt in l1 if elt not in l2]
# l1 = ['a', 'd', 'f']
Example 2: delete all elements in list python
mylist = [1, 2, 3, 4]
mylist.clear()
print(mylist)
# []