1. Overview
The issuperset() method returns True if a set has every elements of another set (passed as an argument). If not, it returns False.
Set X is said to be the superset of set Y if all elements of Y are in X.

Here, set B is a superset of set A and A is a subset of set B.
The syntax of issuperset()
is:
A.issuperset(B)
The following code checks if A is a superset of B.
2. Return Value from issuperset()
issuperset()
returns
- True if A is a superset of B
- False if A is not a superset of B
3. Example: How issuperset() works?
A = {1, 2, 3, 4, 5} B = {1, 2, 3} C = {1, 2, 3} # Returns True print(A.issuperset(B)) # Returns False print(B.issuperset(A)) # Returns True print(C.issuperset(B))
Output
True False True
If you need to check if a set is a subset of another set, you can useĀ issubset() in Python.
Related posts:
Python String count()
Python abs()
Python Program to Return Multiple Values From a Function
Python Program to Merge Mails
Python Program to Find Armstrong Number in an Interval
Machine Learning Mastery with Python - Understand your data, create accurate models and work project...
Python dir()
Python List copy()
Python super()
Python Dictionary popitem()
Python str()
Python String isdecimal()
Python getattr()
Python String isnumeric()
Python Dictionary items()
Python String index()
Python iter()
Python Program to Find the Largest Among Three Numbers
Python Program to Sort a Dictionary by Value
Python break and continue
Python Program to Create Pyramid Patterns
Python Program to Compute the Power of a Number
Python float()
Learning scikit-learn Machine Learning in Python - Raul Garreta & Guillermo Moncecchi
Python Program to Add Two Matrices
Python Get Current time
Python List Comprehension
Applied Text Analysis with Python - Benjamin Benfort & Rebecca Bibro & Tony Ojeda
Python Program to Check Whether a String is Palindrome or Not
Python Recursion
Python Program to Capitalize the First Character of a String
Python Keywords and Identifiers