Python issubset() - Check if the set is a subset of another set

The issubset() of Python set returns if the set is a subset of another set.

s = {'a', 'b', 'c'}
t = {'a', 'b'}

if t.issubset(s):
    print('subset')
else:
    print('***')

# subset

In the above, t is a subset of s.

s = {'a', 'b', 'c'}
t = {'a', 'b', 'd'}

if t.issubset(s):
    print('subset')
else:
    print('***')

# ***

Inequality symbols in Python set

The inequality symbols can substitute issubset().

s1 = {'a', 'b'}
s2 = {'a', 'b', 'c'}

print(s1 < s2)  # True
print(s1 <= s2)  # True
print(s1 > s2)  # False
print(s1 >= s2)  # False
print(s1 == s2)  # False
print(s1 != s2)  # True

Python Set

Python Tutorial