Python Set symmetric_difference_update() Method
Description
The symmetric_difference_update() method removes elements in the current set that are shared with another specified set, and inserts elements from that other specified set that are different into the current set.
Syntax
Syntax of the symmetric_difference_update() method:
set.symmetric_difference_update(set)
Parameters
- set -- the set to check against
Return Value
none.
Example
In the original set x, remove elements duplicated in set y and insert the non-duplicate elements into set x:
Example 1
x
= {
"
apple
"
,
"
banana
"
,
"
cherry
"
}
y
= {
"
"
,
"
runoob
"
,
"
apple
"
}
x
.
symmetric_difference_update
(
y
)
(
x
)
The output is:
{'google', 'cherry', 'banana', 'runoob'}
Python Sets