I have a list of items. I also have another list of items (subset of original list) I want to be removed from this list.
myitems = [1, 1, 2, 3, 3, 4, 5]
items_to_remove = [1, 4]
The output of this should be [2, 3, 3, 5]
What is the most efficient way all items from items_to_remove
from myitems
?
My current code is:
for item in items_to_remove:
myitems = list(filter((item).__ne__,myitems)
Because my actual use case has lots of items to be removed I am trying to find a more efficient way to do this.