The issuperset()
method checks if a set is a superset 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 a superset of another, or False
if it is not.
car_brands_set_one
is a superset of car_brands_set_four
.
car_brands_set_three
is a superset of car_brands_set_two
.
car_brands_set_four
is a not superset 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_one.issuperset(car_brands_set_four))
print(car_brands_set_three.issuperset(car_brands_set_two))
print(car_brands_set_four.issuperset(car_brands_set_three))
True
True
False
To learn more about Sets, read this post Python Set: a quick reference