Python Set issuperset() MethodPython Functions

Difficulty Level:
Difficulty Level:

The issuperset() method is used to check if one set is a superset of another set (passed as an argument).

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

A = {1, 2, 3, 4}
B = {1, 2 }
C = {1, 2}

# Returns True
print(A.issuperset(B))

# Returns False
print(B.issuperset(A))

# Returns True
print(C.issuperset(B))

Output:

True
False
True

Syntax

x.issuperset(y)

Parameters

y- the set to be checked.

Return Value

It returns True if the set has every element of another set, otherwise, it returns False.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us