Only so called hashable objects can be used as dictionary keys in Python. But which object is hashable then?
Many people mistakenly say that only immutable data types are hashable. But it is not entirely correct. Object is hashable if hash() function returns the same value for it throughout the program execution.
Among provided answers - String and Integer are hashable. Immutable data types are subset of all hashable types in Python.
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать