Home / Python / Reference / Set methods

Python set issubset() method

Check whether every item of this set is also in the other.

Syntax

set.issubset(other) / a <= b

issuperset (a >= b) is the reverse check.

Parameters

otherthe other set

Return value

bool

Example

Code

required = {"name", "email"}
given = {"name", "email", "phone"}
print(required.issubset(given), required <= given)
print(given.issuperset(required))

Output

True True
True

Related

Learn it step by step in the free lesson Dictionaries & Sets, with exercises that check your answers.