Python Set isdisjoint() Method
Description
The isdisjoint() method determines whether two sets contain the same elements, returning True if not and False otherwise..
Syntax
Syntax of the isdisjoint() method:
set.isdisjoint(set)
Parameters
- set -- required, the set to compare
Return Value
Returns a Boolean; True if there is no overlap, otherwise False.
Example
Determine whether set y contains elements of set x:
Example 1
x
= {
"
apple
"
,
"
banana
"
,
"
cherry
"
}
y
= {
"
"
,
"
runoob
"
,
"
"
}
z
=
x
.
isdisjoint
(
y
)
(
z
)
The output is:
True
Returns False if it does contain them:
Example 1
x
= {
"
apple
"
,
"
banana
"
,
"
cherry
"
}
y
= {
"
"
,
"
runoob
"
,
"
apple
"
}
z
=
x
.
isdisjoint
(
y
)
(
z
)
The output is:
False
Python Sets