![]() |
VOOZH | about |
Python set issubset() method returns True if all elements of a set A are present in another set B which is passed as an argument, and returns False if all elements are not present in Python.
Syntax: set_obj.issubset(other_set)
Parameter:
- other_set: any other set to compare with.
Return: bool
This code checks if set s2 is a subset of set s1 and prints True if it is.
Output:
TrueIn this code, it checks whether set A is a subset of set B and then whether set B is a subset of set A. The first print statement returns True because all elements of set A are also in set B. The second print statement returns False because set B contains elements that are not in set A.
Output
True
False
In this code, It checks if one set is a subset of another set using the .issubset() method.
Output
True
False
False
True