I have this list:
list = [{1,2,3,4}, {3,4,5}, {2,6}]
I want to have this as the output:
{1,6}
So I only want the unique numbers to have an output. This is what I tried, but it does not work:
list = [{1,2,3,4}, {3,4,5}, {2,6}]
s1 = []
for number in list:
if number not in s1:
s1.append(number)
def unique(s1):
return set.difference(*s1)
print (unique(s1))
My output is:
{1, 2, 3, 4}
I have no clue how to fix this? I am a python beginner so can anyone explain what the answer is and why that should be the solution? Many thanks in advance!