Python Set isdisjoint() Method
Example
If all items in set x do not exist in set y, return True:
x = {"apple", "banana", "cherry"} y = {"google", "microsoft", "facebook"} z = x.isdisjoint(y) print(z)
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, return False:
x = {"apple", "banana", "cherry"} y = {"google", "microsoft", "apple"} z = x.isdisjoint(y) print(z)