Python Set issuperset() Method

Returns True if all the items in the other set exist in the source set.

Syntax

Python
set.issuperset(otherSet)

Parameters

ParameterDescription
otherSet Required. The set to compare with the current set

Example

Python
desktopComponents = {'memory', 'processor'}
laptopComponents = {'memory', 'processor', 'SSD', 'camera', 'keyboard'}

desktopIsSuperset = desktopComponents.issuperset(laptopComponents)
laptopIsSuperset = laptopComponents.issuperset(desktopComponents)

print(f'Desktop computer components are a superset of a laptop computer components: {desktopIsSuperset}')
print(f'Laptop computer components are a superset of a desktop computer components: {laptopIsSuperset}')

Output

Desktop computer components are a superset of a laptop computer components: False
Laptop computer components are a superset of a desktop computer components: True