Python Set isdisjoint
Now, we are going to understand the isdisjoint method. If you are already familiar with what disjoint sets are, it is well and good, but even if things are new for you, do not worry, since we are going to study the concept from basics, so that you can simply follow along.
Let’s consider that there are two sets set1, and set2. Now, set1 and set2 are said to be disjoint sets, if they do not have any elements in common. So, the method isdisjoint is going to return True, if the two sets are disjoint, and otherwise, it is going to return False.
Python Set isdisjoint() Method
As you can see in the above program, we have two sets. So, we are then trying to check if the two sets are disjoint. In the above set, the output would be False, since these sets are not disjoint. The thing is that if the two sets are disjoint, they have no elements in common, which is not true in the above case, so the output is False.
So, whenever we need to check if the two sets are disjoint or not, we can simply use the isdisjoint method. Remember that the two sets are disjoint when they do not have any elements in common.