Python Set issubset() MethodPython Functions

Difficulty Level:
Difficulty Level:

The issubset() method returns True if all elements of one set exist in another set, otherwise, it returns False.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

A = {1,2,3,4}
B = {1, 2, 3,4,5,6}
C = {1,11}

print("The issubset between set A and set B is",A.issubset(B))

print("The issubset between set A and set C is",A.issubset(C))

print("The issubset between set C and set B is",B.issubset(C))

Output:

The issubset between set A and set B is True
The issubset between set A and set C is False
The issubset between set C and set B is False

Syntax

set_x.issubset(set_y)

Parameters

set-y — the set to search for equal items in one set.

Return Value

It returns True or False.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us