How to find the symmetric difference of two sets in Python

1 Answer

0 votes
st1 = {'python', 'java', 'c', 'c++', 'c#'}
st2 = {'c', 'c++', 'php', 'nodejs'}

st1.symmetric_difference_update(st2)

print(st1)
print(st2)




'''
run:

{'java', 'php', 'nodejs', 'c#', 'python'}
{'c++', 'nodejs', 'c', 'php'}

'''

 



answered Aug 10, 2022 by avibootz

Related questions

1 answer 170 views
3 answers 268 views
1 answer 178 views
1 answer 117 views
1 answer 160 views
1 answer 143 views
1 answer 163 views
...