Hello everyone,
I have two lists of strings, and I want to find the difference between them, but only with unique entries. I want the output to be ['apple', 'banana', 'kiwi']
, because 'apple'
and 'banana'
are in list1
but not in list2
, and 'kiwi'
is in list2
but not in list1
.
Here’s the code I have tried so far:
This works for finding the difference between the two lists, but it doesn’t give me the unique entries. I tried using set()
to remove duplicates, but that removes all duplicates, not just duplicates between the two lists.
Can someone please suggest a more efficient way to get the difference between two lists with unique entries?
Thanks in advance!