Python Set isdisjoint() Method

Example

If there are no items in set y that exist in all sets x, it returns True:

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "facebook"}
z = x.isdisjoint(y) 
print(z)

Run Instance

Definition and Usage

If no items exist in the same set, the isdisjoint() method returns True, otherwise it returns False.

Syntax

set.isdisjoint(set)

Parameter Value

Parameter Description
set Required. The set in which the same items are to be retrieved.

More Examples

Example

What if there are items that exist in the same set at the same time?

If one or more items exist in both sets, it returns False:

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.isdisjoint(y) 
print(z)

Run Instance