1. Overview
The issubset() method returns True if all elements of a set are present in another set (passed as an argument). If not, it returns False.
Set A is said to be the subset of set B if all elements of A are in B.

Here, set A is a subset of B.
The syntax of issubset()
is:
A.issubset(B)
The above code checks if A is a subset of B.
2. Return Value from issubset()
issubset()
returns
- True if A is a subset of B
- False if A is not a subset of B
3. Example: How issubset() works?
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))
Output
True False False True
If you need to check if a set is a superset of another set, you can use issuperset() in Python.
Related posts:
Python id()
Python Program to Shuffle Deck of Cards
Python Program to Check if a Number is Positive, Negative or 0
Python Program to Find LCM
Python String capitalize()
Python Shallow Copy and Deep Copy
Python strftime()
Python property()
Python range()
Python Program to Check If a String Is a Number (Float)
Python Program to Find the Size (Resolution) of a Image
Python Numbers, Type Conversion and Mathematics
Python Dictionary get()
Python Program to Return Multiple Values From a Function
Python String rindex()
Python Program to Represent enum
Python String isalnum()
Python Statement, Indentation and Comments
Python Set difference_update()
Python Program to Find the Square Root
Python Program to Get the File Name From the File Path
Python Program to Trim Whitespace From a String
Python Program to Convert Decimal to Binary, Octal and Hexadecimal
Python Tuple count()
Python Set copy()
Python Dictionary clear()
Python Program to Check Whether a String is Palindrome or Not
Python String rsplit()
Python String startswith()
Python Program to Get File Creation and Modification Date
Python input()
Python Program to Display Powers of 2 Using Anonymous Function