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 maketrans()
Python Program to Check if a Number is Positive, Negative or 0
Statistical Methods for Machine Learning - Disconver how to Transform data into Knowledge with Pytho...
Python Program to Create a Countdown Timer
Python bin()
Python 3 for Absolute Beginners - Tim Hall & J.P Stacey
Python Dictionary items()
Python Program to Sort Words in Alphabetic Order
Python Program to Safely Create a Nested Directory
Python Dictionary clear()
Python String format()
Python Program to Compute the Power of a Number
Python String encode()
Python String strip()
Python String rjust()
Python classmethod()
Python Program to Convert String to Datetime
Python String format_map()
Python Program to Delete an Element From a Dictionary
Python isinstance()
Python Functions
Python vars()
Python abs()
Python Program to Extract Extension From the File Name
Python Program to Create a Long Multiline String
Python eval()
Python iter()
Python time Module
Python Set difference()
Python Program to Find Sum of Natural Numbers Using Recursion
Python Set isdisjoint()
Python max()