Python Function Reference

set.issubset

Check that every item of the set is in other.

Python 3.13
set.issubset(other)

Parameters

otherIterable
The collection to compare the set with.

Return value

True or False; an empty set is a subset of any set.

Examples

Subset check

Python 3.13
print({1, 2}.issubset({1, 2, 3}))
True

An equal set is a subset too

Python 3.13
a = {1, 2}
print(a.issubset([2, 1]), a < {1, 2})
True False

Details

For sets, the <= operator does the same, and the < operator also checks that the sets are not equal.

See also

Where to learn