Python Set issuperset() Method
Returns True
if all the items in the other set exist in the source set.
Syntax
Python
Copy Code
set.issuperset(otherSet)
Parameters
Parameter | Description |
---|---|
otherSet |
Required. The set to compare with the current set |
Example
Python
Copy Code
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