English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The symmetric_difference_update() method finds the symmetric difference set of two sets and updates the set it calls.
The symmetric difference of two sets A and B is the set of elements that are in A or B but not in their intersection.
The syntax of symmetric_difference_update() is:
A.symmetric_difference_update(B)
symmetric_difference_update() returns None (does not return any content). And it updates the set it calls.
A = {'a', 'c', 'd'} B = {'c', 'd', 'e'} result = A.symmetric_difference_update(B) print('A =', A) print('B =', B) print('result =', result)
Output result
A = {'a', 'e'} B = {'d', 'c', 'e'} result = None
Here, set A is updated to the symmetric difference of set A and set B. But set B does not change.
Recommended reading: Python Set symmetric_difference()