Python 3 reference · Set Methods

Python Set issubset() Method

Return True if every element of this set is also in the other. The same as a <= b.

Python 3 Since 3.0

Syntax

set.issubset(other)

Parameters

ParameterDescription
other An iterable.

Return value

True or False.

Examples

Subset and proper subsetTry it yourself
print({1, 2}.issubset({1, 2, 3}), {1, 4} <= {1, 2, 3}, {1, 2} < {1, 2})

Output

True False False
Are all required fields present?Try it yourself
required = {"name", "email"}
form = {"name": "Ada", "email": "[email protected]", "age": 36}
print(required.issubset(form))

Output

True

Version history

VersionChange
Python 3.0Added