issubset() in python
The 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 not present.
Syntax:
A.issubset(B) checks whether A is a subset of B or not. Returns: returns true if A is a subset of B otherwise false.

# Python program to demonstrate working of # issubset(). A = {4, 1, 3, 5} B = {6, 0, 4, 1, 5, 0, 3, 5} # Returns True print(A.issubset(B)) # Returns False # B is not subset of A print(B.issubset(A)) |
chevron_right
filter_none
Output:
True False
# Another Python program to demonstrate working # of issubset(). A = {1, 2, 3} B = {1, 2, 3, 4, 5} C = {1, 2, 4, 5} # Returns True print(A.issubset(B)) # Returns False # B is not subset of A print(B.issubset(A)) # Returns False print(A.issubset(C)) # Returns True print(C.issubset(B)) |
chevron_right
filter_none
Output:
True False False True
Recommended Posts:
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- try and except in Python
- abs() in Python
- chr() in Python
- SHA in Python
- Any & All in Python
- SQL using Python | Set 1
- Python | a += b is not always a = a + b
- Python Set | pop()
- max() and min() in Python
- pow() in Python
- set add() in python
- gcd() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.



