issubset () in python

Python Methods and Functions

Syntax :

 A.issubset (B) checks whether A is a subset of B or not.  Returns:  returns true if A is a subset of B otherwise false. 

# Python program to demonstrate how it works
# issubset ().

 

A = { 4 , 1 , 3 , 5 }

B = { 6 , 0 , 4 < code class = "plain">, 1 , 5 , 0 , 3 , 5 }

 
# Returns True

print (A.issubset (B))

 
# Returns False
# B is not a subset of A

print (B.issubset (A))

Output:

 True False 

# Another Python program for de monster work
# of issubset ().

A = { 1 , 2 , 3 }

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

C = { 1 , 2 , 4 , 5 }

 
# Returns True

print (A.issubset (B))

 
# Returns False
# B is not a subset of A

print (B.issubset (A))

 
# Returns False

print (A.issubset (C))

 
# Returns True

print (C.issubset (B))

Output:

 True False False True 




Tutorials