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 String isnumeric()
Python Data Structures and Algorithms - Benjamin Baka
Python dir()
Python oct()
Python Program to Find Factorial of Number Using Recursion
Python Program to Display Calendar
Python Program to Sort a Dictionary by Value
Deep Learning from Scratch - Building with Python form First Principles - Seth Weidman
Python String rpartition()
Python Set pop()
Python if...else Statement
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Program to Iterate Through Two Lists in Parallel
Python Program to Count the Number of Occurrence of a Character in String
Python Program to Reverse a Number
Python Program to Count the Occurrence of an Item in a List
Python Errors and Built-in Exceptions
Python Program to Print Colored Text to the Terminal
Python repr()
Python map()
Python timestamp to datetime and vice-versa
Python String isidentifier()
Python String splitlines()
Python Program to Check Leap Year
Python Program to Trim Whitespace From a String
Python str()
Python Closures
Python String swapcase()
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python Program to Find HCF or GCD
Python Set symmetric_difference()
Python Data Analytics with Pandas, NumPy and Matplotlib - Fabio Nelli