Python Set issubset() Method Tutorial

In this section, we will learn what the Set issubset() method is and how to use it in Python.

What is Set issubset() Method in Python?

The Python Set issubset() method is used to check if the elements of the Set object that invoked this method is a sub-set of a Set object that we put as the argument of this method.

Python Set issubset() Method Syntax:

set.issubset(Set)

Set issubset() Method Parameter:

The method takes one argument and that is a reference to a Set object.

Set issubset() method Return Value

The return value of this method is of type boolean.

The value True will return if the entire elements of the original Set object (the one that this method is invoked with) are in the reference Set object as well (the argument of the method). Otherwise the value False will return instead.

Example: using python set issubset() method

set1 = {1,2,3,4,5}

set2 = {1,2,3,4,5,500,600,700}

result = set1.issubset(set2)

print(result)

Output:

True
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies