how to delete the element from list in python 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: how to remove things from a list python
l = ['Alice', 'Bob', 'Charlie', 'Bob', 'Dave']
print(l)
# ['Alice', 'Bob', 'Charlie', 'Bob', 'Dave']
l.remove('Alice')
print(l)
# ['Bob', 'Charlie', 'Bob', 'Dave']