Table of Contents
The isdisjoint() method returns True if two sets are disjoint sets. If not, it returns False.
Two sets are said to be disjoint sets if they have no common elements. For example:
A = {1, 5, 9, 0}
B = {2, 4, -5}
Here, sets A and B are disjoint sets.

The syntax of isdisjoint() is:
set_a.isdisjoint(set_b)
1. isdisjoint() Parameters
isdisjoint() method takes a single argument (a set).
You can also pass an iterable (list, tuple, dictionary, and string) to disjoint(). isdisjoint() method will automatically convert iterables to set and checks whether the sets are disjoint or not.
2. Return Value from isdisjoint()
isdisjoint() method returns
Trueif two sets are disjoint sets (if set_a and set_b are disjoint sets in above syntax)Falseif two sets are not disjoint sets
3. Example 1: How isdisjoint() works?
A = {1, 2, 3, 4}
B = {5, 6, 7}
C = {4, 5, 6}
print('Are A and B disjoint?', A.isdisjoint(B))
print('Are A and C disjoint?', A.isdisjoint(C))
Output
Are A and B disjoint? True Are A and C disjoint? False
4. Example 2: isdisjoint() with Other Iterables as arguments
A = {'a', 'b', 'c', 'd'}
B = ['b', 'e', 'f']
C = '5de4'
D ={1 : 'a', 2 : 'b'}
E ={'a' : 1, 'b' : 2}
print('Are A and B disjoint?', A.isdisjoint(B))
print('Are A and C disjoint?', A.isdisjoint(C))
print('Are A and D disjoint?', A.isdisjoint(D))
print('Are A and E disjoint?', A.isdisjoint(E))
Output
Are A and B disjoint? False Are A and C disjoint? False Are A and D disjoint? True Are A and E disjoint? False
Related posts:
Python abs()
Python zip()
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Dictionary popitem()
Python Program to Convert Two Lists Into a Dictionary
Python Machine Learning Second Edition - Sebastian Raschka & Vahid Mirjalili
Python Tuple index()
Python Errors and Built-in Exceptions
Python Program to Catch Multiple Exceptions in One Line
Python Directory and Files Management
Python Program to Convert Decimal to Binary Using Recursion
Python Program to Sort Words in Alphabetic Order
Python slice()
Python List append()
Python timestamp to datetime and vice-versa
Python List
Python Program to Copy a File
Python Program to Parse a String to a Float or Int
Python eval()
Python Program to Find All File with .txt Extension Present Inside a Directory
Introduction to Scientific Programming with Python - Joakim Sundnes
Python memoryview()
Python String expandtabs()
Python Program to Merge Mails
Python Program to Check the File Size
Converting Between an Array and a Set in Java
Python String title()
Python globals()
Python dict()
Python Global, Local and Nonlocal variables
Python Program to Return Multiple Values From a Function
Node.js vs Python for Backend Development