delete items from the list present in another list 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 delete a particular element from a list in python
# animals list
animals = ['cat', 'dog', 'dog', 'guinea pig', 'dog']
# 'dog' is removed
animals.remove('dog')
# Updated animals list
print('Updated animals list: ', animals)