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)
- Python | Convert list to Python array
- Important differences between Python 2.x and Python 3.x with examples
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- Python | Index of Non-Zero elements in Python list
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to Python Libraries
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Visualizing O(n) using Python
- try and except in Python
- Any & All in Python
- SHA in Python
- SQL using Python | Set 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.