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 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python sorted()
Java Program to Implement Dijkstra’s Algorithm using Set
Python Program to Find All File with .txt Extension Present Inside a Directory
Java Program to Implement the Binary Counting Method to Generate Subsets of a Set
Python Set pop()
Python String upper()
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Machine Learning with Python for everyone - Mark E.Fenner
Python timestamp to datetime and vice-versa
Python Deep Learning - Valentino Zocca & Gianmario Spacagna & Daniel Slater & Peter Roelants
Python Program to Make a Flattened List from Nested List
Python String lower()
Python Machine Learning - Sebastian Raschka
Python del Statement
Python Program to Check If Two Strings are Anagram
Python Program to Generate a Random Number
Python Program to Create Pyramid Patterns
Python object()
Python Dictionary clear()
Python any()
Python Data Structures and Algorithms - Benjamin Baka
Python Generators
Python Program to Remove Punctuations From a String
Python Set update()
Python Tuple count()
Python reversed()
Python Program to Find the Factors of a Number
Python Multiple Inheritance
Deep Learning with Python - A Hands-on Introduction - Nikhil Ketkar
Python Program to Get the File Name From the File Path
Introduction to Scientific Programming with Python - Joakim Sundnes