seen = set() # a tuple is hashable seen.add((1, 2)) print((1, 2) in seen) try: # a list is not seen.add([3, 4]) except TypeError as e: print("unhashable:", e)
only immutable objects can be dict keys or set members