set.symmetric_difference_update() in python



"symmetric_difference_update()" function is used to find the uncommon elements in the given two set and update the elements in the specified set.


Syntax:




set.symmetric_difference_update(set_value)







Example-1
n = {10, 30, 50}

m = {10, 30, 100}

n.symmetric_difference_update(m)

print(n)


Output



{100, 50}







Example-2
n = {10, 30, 50, 20, 40}

m = {10, 30, 100}

n.symmetric_difference_update(m)

print(n)


Output



{100, 40, 50, 20}







Example-3
n = {"A", "B", "C"}

m = {"A", "B", "D"}

n.symmetric_difference_update(m)

print(n)


Output



{'D', 'C'}