.issuperset()
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:
Contribute to Docs
- 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.
Learn Python on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours