Python Set Symmetric Difference || Difference || Sets || Python
In this we are going to see a basic program which performs difference and symmetric difference between two sets in Python Programming Language.


set1 = {4, 7, 1, 3, 5, 6, 8, 9, 2}
set2 = {10, 12, 1, 3, 8, 11, 5, 9}
print("Set1 : ", set1)
print("Set2 : ", set2)

# For Difference Of Two Sets
set3 = set1.difference(set2)
print("-------------------------------------")
print("After Difference Of Two Sets, The Set Is : ", set3)

set1 = {4, 7, 1, 3, 5, 6, 8, 9, 2}
set2 = {0, 2, 1, 3, 8, 11, 5, 9, 10}
print("Set1 : ", set1)
print("Set2 : ", set2)

# For Symmetric Difference Of Two Sets
set3 = set1.symmetric_difference(set2)
print("-------------------------------------")
print("After Symmetric Difference Of Two Sets, The Set Is : ", set3)

# Coded By DHIRAJ SHELKE


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post