When it is required to check if one tuple is a subset of the other, the 'issubset' method is used.
The 'issubset' method returns True if all the elements of the set are present in another set, wherein the other set would be passed as an argument to the method.
Otherwise, this method returns False.
Below is a demonstration of the same −
my_tuple_1 = (87, 90, 31, 85) my_tuple_2 = (34, 56, 12, 5) print("The first tuple is :") print(my_tuple_1) print("The second tuple is :") print(my_tuple_2) my_result = set(my_tuple_2).issubset(my_tuple_1) print("Is the second tuple a subset of the first tuple ? ") print(my_result)
The first tuple is : (87, 90, 31, 85) The second tuple is : (34, 56, 12, 5) Is the second tuple a subset of the first tuple ? False