YouTip LogoYouTip

Ref Set Issubset

# Python3.x Python Set issubset() Method [![Image 3: Python3 Lists](#) Python Sets](#) * * * ## Description The issubset() method is used to check whether all elements of a set are contained in the specified set. If they are, it returns True; otherwise, it returns False. ## Syntax The syntax for the issubset() method is: set.issubset(set) ## Parameters * set -- Required, the set to compare against. ## Return Value Returns a boolean value. Returns True if all elements are contained, otherwise returns False. ## Example Check if all elements of set x are contained in set y: ## Example 1 x = {"a", "b", "c"} y = {"f", "e", "d", "c", "b", "a"} z = x.issubset(y)print(z) The output is: True If not all elements are contained, it returns False: ## Example 1 x = {"a", "b", "c"} y = {"f", "e", "d", "c", "b"} z = x.issubset(y)print(z) The output is: False [![Image 4: Python3 Lists](#) Python Sets](#)
← Ref Set PopRef Set Intersection_Update β†’