w3resource logo


Python Exercises

Python Exercise: Symmetric difference

Python sets: Exercise-9 with Solution

Write a Python program to create a symmetric difference.

Sample Solution :-

Python Code :

setx = set(["apple", "mango"])
sety = set(["mango", "orange"])
#Symmetric difference
setc = setx ^ sety
print(setc)

Output :

{'apple', 'orange'}

Python Code Editor:

setx = set(["apple", "mango"])
sety = set(["mango", "orange"])
#Symmetric difference
setc = setx ^ sety
print(setc)

Improve this sample solution and post your code through Disqus.



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program