In Python, How can one subtract two non-unique, unordered lists? Say we have a = [0,1,2,1,0] and b = [0, 1, 1] I\'d like to do something like
a = [0,1,2,1,0]
b = [0, 1, 1]
I would do it in an easier way:
a_b = [e for e in a if not e in b ]
..as wich wrote, this is wrong - it works only if the items are unique in the lists. And if they are, it's better to use
a_b = list(set(a) - set(b))