Skip to content
Related Articles

Related Articles

issuperset() in Python

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 17 Aug, 2022
Improve Article
Save Article

Python Set issuperset() method returns True if all elements of a set B are in set A. Then Set A is the superset of set B.

Python issuperset() Method Syntax:

Syntax: A.issuperset(B)

Parameter: Any other Set to compare with

Return: boolean value

issuperset() in Python

 

Python issuperset() example

Example 1: Working of issubset() with two sets

Python3




A = {4, 1, 3, 5}
B = {6, 0, 4, 1, 5, 0, 3, 5}
 
print("A.issuperset(B) : ", A.issuperset(B))
print("B.issuperset(A) : ", B.issuperset(A))

Output:

A.issuperset(B) :  False
B.issuperset(A) :  True

Example 2: Working of Python issubset() Method with three Sets

Here we have use 3 different Sets to demonstrate the working of Python Set issubset() Method

Python




A = {1, 2, 3}
B = {1, 2, 3, 4, 5}
C = {1, 2, 4, 5}
 
print("A.issuperset(B) : ", A.issuperset(B))
print("B.issuperset(A) : ", B.issuperset(A))
print("A.issuperset(C) : ", A.issuperset(C))
print("C.issuperset(B) : ", C.issuperset(B))

Output: 

A.issuperset(B) :  False
B.issuperset(A) :  True
A.issuperset(C) :  False
C.issuperset(B) :  False
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!