4 ms·
Yes, Python has both a set type and the immutable "frozenset" type, that can be used as a dictionary key. someset = {"one", "two", "three"} "one" in someset #
by Scarblac 8y ago
Yes, Python has both a set type and the immutable "frozenset" type, that can be used as a dictionary key.
someset = {"one", "two", "three"}
"one" in someset # true
frozen = frozenset(someset)
somedict = {frozen: "example"}
frozen in somedict # true
somedict[frozen] # "example"