- isdisjoint() is a python function which return True or False value.
- It return True if two sets are disjoint to each other i.e. nothing common.
- It return False if two set are not disjoint to each other.
Syntax-
set1.isdisjoint(set2)
Example
set1 is {1,2,3}
set2 is {4,5}
then isdisjoint() will return True
set1 is {1,2,3,4}
set2 is {4,5}
then isdisjoint() will return False
program-
set1={4,5,6}
set2={9,8,7,6,5,4,3}
print("Set1 is",set1)
print("Set2 is",set2)
print(set1.isdisjoint(set2))
set1={1,2,3}
set2={4,5,6}
print("Set1 is",set1)
print("Set2 is",set2)
print(set1.isdisjoint(set2))
Set1 is {4, 5, 6}
Set2 is {3, 4, 5, 6, 7, 8, 9}
False
Set1 is {1, 2, 3}
Set2 is {4, 5, 6}
True