Syntax error issuperset() in Python

issuperset() in Python



In this article, we will learn about issuperset() in Python and its implementation in various areas.

This method returns boolean True if all elements of a set B contains all elements set A which is passed as an argument and returns false if all elements of A not present in B.

This means if B is a superset of A then it

returns true;
else False

Example

Let’s look at some example

 Live Demo

A = {'t','u','t','o','r','i','a','l'}
B = {'t','u','t'}
print("A issuperset B : ", A.issuperset(B))
print("B issuperset A : ", B.issuperset(A))

Output

A issuperset B : True
B issuperset A : False

Example

 Live Demo

A = {'t','u','t','o','r','i','a','l'}
B = {'t','u','t'}
C = {'o','r','i','a','l'}
print("A issuperset B : ", A.issuperset(B))
print("B issuperset A : ", B.issuperset(A))
print("A issuperset C : ", A.issuperset(C))
print("B issuperset C : ", B.issuperset(C))

Output

A issuperset B : True
B issuperset A : False
A issuperset C : True
B issuperset C : False

Conclusion

In this article, we learnt how to implement the issuperset() function in Python 3.x. Or earlier.

Updated on: 2019-08-29T10:48:29+05:30

142 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements