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
| Parameter | Description |
|---|---|
other |
An iterable. |
Return value
True or False.
Examples
print({1, 2}.issubset({1, 2, 3}), {1, 4} <= {1, 2, 3}, {1, 2} < {1, 2})
Output
True False False
required = {"name", "email"}
form = {"name": "Ada", "email": "[email protected]", "age": 36}
print(required.issubset(form))
Output
True
Version history
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
set.issuperset()· Return True if this set contains every element of the other. The same as a >= b.set.isdisjoint()· Return True if the set has no elements in common with another iterable.- Python Sets · tutorial