isdisjoint() function in Python

Two sets are said to be disjoint when their intersection is null. In simple words they do not have any common element in between them.


Let set A = {2, 4, 5, 6}
and set B = {7, 8, 9, 10} 

set A and set B are said to be be disjoint sets as their
intersection is null. They do-not have any common elements in between them. 




The isdisjoint() method takes only a single argument.
It can also take an iterable (list, tuple, dictionary and string) to disjoint(). The isdisjoint() method will automatically convert iterables to set and checks whether the sets are disjoint or not.

Return Value:

returns Trueif the two sets are disjoint.
returns Falseif the twos sets are not disjoint.

Below is the Python3 implementation of the above approach:





# Python3 program for isdisjoint() function
set1 = {2, 4, 5, 6
set2 = {7, 8, 9, 10}
set3 = {1, 2}
#checking of disjoint of two sets
print("set1 and set2 are disjoint?", set1.isdisjoint(set2))
print("set1 and set3 are disjoint?", set1.isdisjoint(set3))



set1 and set2 are disjoint? True
set1 and set3 are disjoint? False

My Personal Notes arrow_drop_up

Striver(underscore)79 at Codechef and codeforces D

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.