VOOZH about

URL: https://www.geeksforgeeks.org/python/python-set-isdisjoint-method/

⇱ Python Set isdisjoint() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python Set isdisjoint() Method

Last Updated : 4 Apr, 2023

Python set isdisjoint() function check whether the two sets are disjoint or not, if it is disjoint then it returns True otherwise it will return False. Two sets are said to be disjoint when their intersection is null. 

Python set isdisjoint() Method Syntax:

Syntax: set1.isdisjoint(set2)

Parameters:

  • another set to compare with
    or
  • an iterable (list, tuple, dictionary, and string)

Return: bool

Python Set isdisjoint() Method Example:

Output:

True

Example 1: Working with Set isdisjoint() Method

Output: 

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

Example 2: Python Set isdisjoint() with Other Iterables as arguments

Output:

Set A and List lis disjoint? False
Set A and dict are disjoint? False
Set A and dict2 are disjoint? True

Example 3 : Both the sets are empty

Here we will see what will be the output if we use the isdisjoint() method with two sets both are empty.


Output
True
Comment
Article Tags: