Python Set issuperset() Method

Determines whether all items in the specified set are present in the original set

Usage

The issuperset() method returns True if all items in the specified set are present in the original set, otherwise FALSE.

Syntax

set.issuperset(set)

Python set issuperset() method parameters
ParameterConditionDescription
setRequiredA set to search for common items in

Basic Example

Example: Check if all items in B are present in A

A = {'red', 'green', 'blue', 'yellow'}
B = {'yellow', 'red'}

print(A.issuperset(B))	# True

Venn Diagram:

Superset

Equivalent Operator >=

You can achieve the same result by using the >= comparison operator.

Example:

A = {'red', 'green', 'blue', 'yellow'}
B = {'yellow', 'red'}

print(A >= B)	# True

Find Proper Superset

To test whether the set is a proper superset of other, use > comparison operator.

Set A is considered a proper superset of B, if A is a superset of B, but A is not equal to B.

Example: Check if A is a proper superset of B

A = {'red', 'green', 'blue', 'yellow'}
B = {'yellow', 'red'}

print(A > B)	# True
A = {'yellow', 'red'}
B = {'yellow', 'red'}

print(A > B)	# False