Python Set issuperset() Method
Example
Return True if all items set
y
are present in set
x
:
x = {"f", "e", "d",
"c", "b", "a"}
y = {"a", "b", "c"}
z = x.issuperset(y)
print(z)
Try it Yourself »
Definition and Usage
The issuperset()
method returns True if all items
in the specified set exists in the original set, otherwise it returns False.
As a shortcut, you can use the >=
operator instead, see example below.
Syntax
set.issuperset(set)
Shorter Syntax
set >= set1
Parameter Values
Parameter | Description |
---|---|
set | Required. The set to search for equal items in |
More Examples
Example
Use >=
as a shortcut instead of
issuperset()
:
x = {"f", "e", "d",
"c", "b", "a"}
y = {"a", "b", "c"}
z = x >= y
print(z)
Try it Yourself »
Example
What if not all items are present in the specified set?
Return False if not all items in set
y
are present in set
x
:
x = {"f", "e", "d",
"c", "b"}
y = {"a", "b", "c"}
z = x.issuperset(y)
print(z)
Try it Yourself »