The symmetric difference of two sets is the set of elements which are in either of the sets but not in both of them.
Symmetric Difference is marked in Green
symmetric_difference() method returns a new set which contains symmetric difference of two sets. The symmetric_difference_update() method updates the set calling symmetric_difference_update() with the symmetric difference of sets.
The symmetric_difference takes a single “set” as a argument.
This method returns None (which indicates absence of a return value). It only updates the set calling symmetric_difference_update() with the symmetric difference of sets.
('A = ', set(['e', 'o', 'p', 'r', 'w'])) ('B = ', set(['a', 'r', 'e', 'o', 'n'])) ('result = ', None)
('A = ', set(['s', 'b'])) ('B = ', set(['y', 'b', 'u', 'n'])) ('result = ', None)
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- SHA in Python
- Python Set | pop()
- Any & All in Python
- max() and min() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.