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 156 views
3 answers 241 views
1 answer 168 views
1 answer 107 views
1 answer 148 views
1 answer 129 views
1 answer 153 views
...