I want to compare two lists and extract unmatched values.
Example:
list1 = ['A1', 'B1', 'C1', 'D1', 'E1']
list2 = ['A1', 'B1', 'D1', 'E1']
so the 'C1' is not in list 2 so I want output as
output: C1
I want to compare two lists and extract unmatched values.
Example:
list1 = ['A1', 'B1', 'C1', 'D1', 'E1']
list2 = ['A1', 'B1', 'D1', 'E1']
so the 'C1' is not in list 2 so I want output as
output: C1
you can use the symmetric_difference
for set
s:
set(list1) ^ set(list2)
# {'C1'}
depending on what you really need, you may need the difference
set(list1) - set(list2)
# {'C1'}