Easy Tutorial
❮ Python Socket Python Check Substring Present Given String ❯

Python Set issubset() Method

Python Set


Description

The issubset() method is used to determine if all elements of a set are contained within a specified set. If so, it returns True; otherwise, it returns False.

Syntax

The syntax for the issubset() method is:

set.issubset(set)

Parameters

Return Value

Returns a Boolean value; True if all elements are included, otherwise False.

Example

Determine if all elements of set x are contained within set y:

Example 1

x = {"a", "b", "c"}
y = {"f", "e", "d", "c", "b", "a"}

z = x.issubset(y)

print(z)

Output:

True

If not all elements are included, it returns False:

Example 2

x = {"a", "b", "c"}
y = {"f", "e", "d", "c", "b"}

z = x.issubset(y)

print(z)

Output:

False

Python Set

❮ Python Socket Python Check Substring Present Given String ❯