If List A= [1,2] and List B=[2,4]
I want the difference between A and B which is present in B.
that is, diff between A and B is [1,4]... should be present in B... SO the final output should be C=[4]
If List A= [1,2] and List B=[2,4]
I want the difference between A and B which is present in B.
that is, diff between A and B is [1,4]... should be present in B... SO the final output should be C=[4]
Using the XOR ^
operator in set:
lst_A = [1,2]
lst_B = [2,4]
print(list(set(lst_A) ^ set(lst_B)))
OUTPUT:
[1,4]