Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Comparing Sets with issubset() Function in python

# The issuperset() function can be used to determine if a set is a superset of
# another set. Let’s see an example:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet.issuperset(mySet2))

# Output:
# False

# Looking at the example above, we can tell by the output that mySet is not a
# superset of mySet2, meaning that mySet does not contain all the values that are
# within mySet2. Let’s see what happens if we check if mySet2 is a superset of mySet:

mySet = {2, 4}
mySet2 = {1, 2, 3, 4, 5}
print(mySet2.issuperset(mySet))

# Output:
# True

# Looking at the example above, we can verify that mySet2 is a superset of mySet.
Source by liu-111.medium.com #
 
PREVIOUS NEXT
Tagged: #Comparing #Sets #Function #python
ADD COMMENT
Topic
Name
6+5 =