Hashability and dictionary keys
Learn in depth →A hashable object has a stable hash and equality behavior suitable for dictionary/set membership.
hash(value); {(key_part_1, key_part_2): value}Example
location = (12, 18)
print({location: "sensor"}[location])Result
sensor
Watch for: A tuple is hashable only if all its elements are hashable. Being immutable alone does not prove an arbitrary object is hashable.
Practise this topic →