Given list1 = [1,2,2,3], list2 = [1,2], what's the simplest way to subtract all element of list2 from list1 to get list list3 = [2,3]
It seems sum work well for two lists but subtraction doesn't.
To clarify: Order doesn't matter. L2 is a subset of L1. Duplicates need to be kept. Therefore can't use set.
>>> [1,2,2,3]+[1,2,3]
[1, 2, 2, 3, 1, 2, 3]
>>> [1,2,2,3]-[1,2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'list' and 'list'