Python Set issuperset() Method

Python3 列表Python Set


Description

The issuperset() method is used to determine whether all elements of the specified set are contained in the original set. If yes, it returns True; otherwise, it returns False.

Syntax

Syntax of the issuperset() method:

set.issuperset(set)

Parameters

  • set -- Required, the set to be compared

Return Value

Returns a boolean value. If all elements are included, it returns True; otherwise, it returns False.

Example

Determine whether all elements of set y are contained in set x:

Example 1

x = {"f", "e", "d", "c", "b", "a"} y = {"a", "b", "c"} z = x.issuperset(y) print(z)

The output result is:

True

If not all elements are included, it returns False:

Example 1

x = {"f", "e", "d", "c", "b"} y = {"a", "b", "c"} z = x.issuperset(y) print(z)

The output result is:

False

Python3 列表Python Set

Other Extensions