.issubset()
The .issubset()
method checks whether all elements in one set exist within another specified set. It returns True
if this condition is met; otherwise, it returns False
.
Syntax
set1.issubset(set2)
set1
: The set whose elements are being checked for existence withinset2
.set2
: The set being searched for the presence of elements from theset1
.
Example
The following example demonstrates the usage of the .issubset()
method:
set_A = {"red", "blue", "green"}set_B = {"pink", "yellow", "red", "blue", "green"}print(set_A.issubset(set_B))
This would print True
, because set_B
contains all of the elements in set_A
. It produces the following output:
True
Codebyte Example
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.