Python Set isdisjoint() Method

Example

If all items in set x do not exist in set y, then return True:

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

Run Instance

Definition and Usage

If no items exist simultaneously in different sets, then the isdisjoint() method returns True, otherwise it returns False.

Syntax

set.isdisjoint(set)

Parameter Values

Parameters 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, then return False:

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

Run Instance