Python Set symmetric_difference_update() Method
Removes the items from the given set that are present in both sets, and inserts the items that are not present in both sets.
Syntax
Python
Copy Code
set.symmetric_difference_update(otherSet)
Parameters
Parameter | Description |
---|---|
otherSet |
Required. The set whose elements will be compared with the given set. |
Example
Python
Copy Code
desktopComponents = {'memory', 'processor', 'hard drive'} laptopComponents = {'memory', 'processor', 'SSD', 'camera', 'keyboard'} desktopComponents.symmetric_difference_update(laptopComponents) print(desktopComponents)
Output
{'SSD', 'keyboard', 'camera', 'hard drive'}