Python set.issuperset() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
set method

Definition

issuperset(other) returns True when the set contains every item of other, and False if even one is missing. Neither collection is changed.

It is the mirror image of issubset(). The two may be equal: a set is a superset of itself. The argument can be any iterable, such as a list of required items.

set.issuperset() is an instance method of the built-in set type: call it on a set with dot notation, such as admin.issuperset(...). No import is needed.

Syntax

Call it on the bigger group, pass the items you need, and use the returned True or False.

python
has_all = s.issuperset(iterable)
has_all = s >= other_set
is_proper = s > other_set
CallWhat it does
{1, 2, 3}.issuperset({1, 2})Returns True: the set contains both 1 and 2.
{1, 2}.issuperset([2, 3])Returns False: 3 is missing from the set.
{1}.issuperset([])Returns True: every set contains the empty collection.

a >= b is the operator form and needs sets on both sides. a > b asks for a proper superset, which also requires a to have at least one extra item.

Method signatures
python
set.issuperset(other)
# returns: True if the set contains every item of other, otherwise False
# raises: TypeError if other is not iterable

Parameters

ParameterDescription
otherAny iterable of items to look for: set, list, tuple, string, range, and so on. It is required: issuperset() with no argument raises TypeError.

Return Value

Return ValueDescription
boolTrue if the set contains every item of other (including when they are equal); False otherwise.

Python Examples

Example 1 — Check a Role Has Every Needed Permission

Test whether each role's permission set contains the permissions a task needs.

python
admin = {"read", "write", "delete", "invite"}
editor = {"read", "write"}
needed = ["read", "write"]

print(admin.issuperset(needed))
print(editor.issuperset(needed))
print(editor.issuperset(admin))

How It Works

  1. Admin has it all. Read and write are both in the admin's permissions, so the answer is True.
  2. An exact match counts. The editor has exactly the needed permissions and nothing extra, which still makes the answer True.
  3. The editor lacks the rest. Delete and invite are not in the editor's set, so editor.issuperset(admin) is False.

Example 2 — Check Whether You Can Cook a Recipe

Compare the pantry with two ingredient lists and report what is missing.

python
pantry = {"flour", "egg", "milk", "sugar", "salt"}
pancakes = ["flour", "egg", "milk"]
cake = ["flour", "egg", "butter", "sugar"]

for name, items in [("pancakes", pancakes), ("cake", cake)]:
    if pantry.issuperset(items):
        print(name, "ready")
    else:
        print(name, "missing", sorted(set(items) - pantry))

How It Works

  1. A list of needs. The recipe ingredients are lists, and issuperset() accepts them without any conversion.
  2. Pancakes are possible. The pantry holds flour, egg, and milk, so the result is True and "ready" is printed.
  3. The cake is not. Butter is not in the pantry, so the test fails and the else branch runs.
  4. Name the gap. Subtracting the pantry from the recipe's items leaves exactly the missing ingredient, "butter".

Example 3 — Compare issuperset() With >= and >

See how equal sets, a smaller set, and an empty list behave with the method and the operators.

python
big = {1, 2, 3}
small = {1, 2}
twin = {3, 2, 1}

print(big.issuperset(small), big >= small, big > small)
print(big.issuperset(twin), big >= twin, big > twin)
print(small.issuperset(big))
print(big.issuperset([]))

How It Works

  1. A real superset. {1, 2, 3} holds everything in {1, 2} and one more item, so all three tests are True.
  2. An equal set. The method and >= say True, but > is False because nothing extra is left over.
  3. The reverse is false. {1, 2} lacks 3, so small.issuperset(big) is False.
  4. Nothing needed. An empty list has no item that could be missing, so the answer is True.

Frequently Asked Questions

True if the set contains every item of the argument, and False if at least one item is missing. An equal set counts as a superset.
They are mirror images. a.issuperset(b) asks whether a contains all of b, while a.issubset(b) asks whether all of a is inside b.
Yes. Any iterable is accepted, so s.issuperset(["a", "b"]) is a quick way to check that several required items are present.
An empty collection has no item that could be missing, so every set contains it. Check for an empty required list separately if that matters.
Yes for two sets, but the >= operator needs sets on both sides. The method also accepts a list, tuple, or string.

Next: set.pop()

Remove and return an arbitrary item; raises KeyError if the set is empty.

pop() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful