I have two lists that contain many of the same items, including duplicate items. I want to check which items in the first list are not in the second list. For example, I mig
You didn't specify if the order matters. If it does not, you can do this in >= Python 2.7:
l1 = ['a', 'b', 'c', 'b', 'c'] l2 = ['a', 'b', 'c', 'b'] from collections import Counter c1 = Counter(l1) c2 = Counter(l2) diff = c1-c2 print list(diff.elements())