Python Set isdisjoint() Method

Determines whether or not two sets have any items in common

Usage

The isdisjoint() method returns True if two sets have no items in common, otherwise FALSE.

Sets are disjoint if and only if their intersection is the empty set.

Syntax

set.isdisjoint(set)

Python set isdisjoint() method parameters
ParameterConditionDescription
setRequiredA set to search for common items in

Examples

Example: Check if two sets have no items in common

A = {'green', 'blue', 'purple'}
B = {'yellow', 'red', 'orange'}

print(A.isdisjoint(B))	# True

Venn Diagram:

Disjoint set

The method returns FALSE if the specified sets have any item in common.

Example:

A = {'red', 'green', 'blue'}
B = {'yellow', 'red', 'orange'}

print(A.isdisjoint(B))  # False