Python Set symmetric_difference_update()

The symmetric_difference_update() method updates the set calling the symmetric_difference_update() with the symmetric difference of sets.

The symmetric difference of two sets is the set of elements that are in either of the sets but not in both.

Learn more about symmetric difference of sets in Python.

The syntax of symmetric_difference_update() is:


symmetric_difference_update() Parameters

The symmetric_difference_update() takes a single argument (set).

Return Value from symmetric_difference_update()

This method returns None (meaning, absence of a return value). It only updates the set calling symmetric_difference_update() method (set A) with the symmetric difference of sets (A and B).

Example: How symmetric_difference_update() works?

A = {'a', 'c', 'd'}
B = {'c', 'd', 'e' }

result = A.symmetric_difference_update(B)

print('A = ', A)
print('B = ', B)
print('result = ', result)

When you run the program, the output will be:

A =  {'a', 'e'}
B =  {'d', 'c', 'e'}
result =  None