Python Collection symmetric_difference() Method
Example
Returns a collection that contains all items from both sets, but excludes items that exist in both sets:
x = {"apple", "banana", "cherry"} y = {"google", "microsoft", "apple"} z = x.symmetric_difference(y) print(z)
Definition and Usage
The symmetric_difference() method returns a collection that contains all items from both sets, but does not contain items that exist in both sets.
Meaning: The returned collection contains a mixture of items that do not exist in both sets.
Syntax
set.symmetric_difference(set)
Parameter Value
Parameter | Description |
---|---|
set | Mandatory. Used to check for matching items in a collection. |