DEV Community

Tommi k Vincent
Tommi k Vincent

Posted on

Comparing Sets in Python

Comparing Set - is the ability to check if a given subset or superset of another set.
The result is True or False depending on the elements present in sets.

Enter the below code to experience it pratically.
DaysA  = set(["Mon","Tue","Wed"])
DaysB  = set(["Mon","Tue","Wed","Thu","Fri","Sat","Sun"])


SubsetRes  = DaysA <= DaysB
SupersetRes  = DaysB >= DaysA

print(SubsetRes)
print(SubsetRes )
Enter fullscreen mode Exit fullscreen mode

output
When the above code is executed here below is the result

True
True

Enter fullscreen mode Exit fullscreen mode

Top comments (0)