Set Methods
Set Methods
Apart from the methods we discussed earlier in the chapter there are some more methods that we can use to manipulate sets.
What if you want to check if items of a particular set are present in another set?
There are a few methods to check this.
• isdisjoint():
The isdisjoint() method checks if items of given set are present in another set. This method returns False if items are present, else it returns True.
Example 1:
Output:
Example 2:
Output:
• issuperset():
The issuperset() method checks if all the items of a particular set are present in the original set. It returns True if all the items are present, else it returns False.
Example 1:
Output:
Example 2:
Output:
• issubset():
The issubset() method checks if all the items of the original set are present in the particular set. It returns True if all the items are present, else it returns False.
Example 1:
Output:
Example 2:
Output: