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 Program to Reverse a Number
Python String rstrip()
Python Program to Check if a Number is Positive, Negative or 0
Python Directory and Files Management
Python RegEx
Python String isspace()
Python List count()
Python Program to Check if a Key is Already Present in a Dictionary
Python Machine Learning Cookbook - Practical solutions from preprocessing to Deep Learning - Chris A...
Python String index()
Python Program to Count the Occurrence of an Item in a List
Python Program to Calculate the Area of a Triangle
Python Program to Find the Size (Resolution) of a Image
Python hasattr()
Python Namespace and Scope
Python while Loop
Python Program to Check Armstrong Number
Python str()
Building Chatbots with Python Using Natural Language Processing and Machine Learning - Sumit Raj
Convert a Map to an Array, List or Set in Java
Python String swapcase()
Python String find()
Python setattr()
Deep Learning in Python - LazyProgrammer
Python Program to Print the Fibonacci sequence
Python String isdigit()
Python Program to Get a Substring of a String
Python Program to Merge Two Dictionaries
Python File I/O Operation
Python String format()
Python List clear()
Python Program to Remove Punctuations From a String