Python set - Inequality symbols and subsets

The inequality symbols can substitute issubset() in Python set.

s1 = {'a', 'b'}
s2 = {'a', 'b', 'c'}

print(s1 < s2)  # True
print(s1 <= s2)  # True
print(s1 > s2)  # False
print(s1 >= s2)  # False
print(s1 == s2)  # False
print(s1 != s2)  # True

Comments

Powered by Markdown

More