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]
You can use the map construct to do this. It looks quite ok, but beware that the map line itself will return a list of Nones.
map
None
a = [1, 2, 3] b = [2, 3] map(lambda x:a.remove(x), b) a