.issuperset()
Dashrath_Patel3 total contributions
Published May 30, 2024
Contribute to Docs
In Python, the .issuperset()
method is used to determine if the original set contains all elements of the specified set. It returns True
if every element of the specified set is also an element of the original set, and False
otherwise.
Syntax
set1.issuperset(set2)
set1
: The set to be examined to determine if its elements are all present inset2
.set2
: The set to be checked to see if it contains all elements fromset1
.
Note: In Python, the
>=
operator can also be used to check if one set is a superset of another, just like the.issuperset()
method.
Example
The following example demonstrates the usage of the .issuperset()
method:
set_A = {"pink", "yellow", "red", "blue", "green"}set_B = {"red", "blue", "green"}print(set_A.issuperset(set_B))
The above code produces the following output:
True
Codebyte Example
The below codebyte example demonstrates the use of the .issuperset()
method:
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.