Home >>Python Set Methods >Python Set isdisjoint() Method

Python Set isdisjoint() Method

Python Set isdisjoint() Method

Python Set isdisjoint() Method in python set takes only a single arguments. Generally, it returns true if the items are not present in both the sets, otherwise it returns False.

Syntax:
set.isdisjoint(set)

Parameter Values

Parameter Description
set Required. The set of items to be search for
Here is an example of Python Set isdisjoint() Method:

a = {"php", "python", "SQL"}
b = {"facebook", "instagram", "google+"}
c = a.isdisjoint(b) 
print(c)

Output:
True
Example 2:

num1 = {23, 65, 12, 43} 
num2 = {35, 76, 42, 10} 
num3 = {23, 12} 
print("num1 and num2 are disjoint?", num1.isdisjoint(num2)) 
print("num1 and num3 are disjoint?", num1.isdisjoint(num3))

Output:
num1 and num2 are disjoint? True
num1 and num3 are disjoint? False

No Sidebar ads