Possible Duplicate:
Python list subtraction operation
I want to remove the common elements between two lists. I mean something like this
a=[1,2,3,4,5,6,7,8]
b=[2,4,1]
# I want the result to be like
res=[3,5,6,7,8]
Is there any simple pythonic way to do this ?
use sets :
res = list(set(a)^set(b))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With