issubset(): checking if a Set is a subset of another Set in Python

The issubset() method checks if a set is a subset of another set, that is, if all the items of one set exist in the other set.

The method returns True if one set is subset of another, or False if it is not.

car_brands_set_four is a subset of car_brands_set_one.

car_brands_set_two is a subset of car_brands_set_three.

car_brands_set_four is not a subset of car_brands_set_three.

car_brands_set_one = {'bmw', 'mclaren', 'ferrari', 'ford'}

car_brands_set_two = {'honda', 'jeep', 'ford'}

car_brands_set_three = {'honda', 'toyota', 'jeep', 'ford'}

car_brands_set_four = {'bmw', 'ford'}

print(car_brands_set_four.issubset(car_brands_set_one))

print(car_brands_set_two.issubset(car_brands_set_three))

print(car_brands_set_four.issubset(car_brands_set_three))
True
True
False

To learn more about Sets, checkout this post Python Set: a quick reference