typeerror 3a unhashable type 3a 27list 27 python dictionary

Solutions on MaxInterview for typeerror 3a unhashable type 3a 27list 27 python dictionary by the best coders in the world

showing results for - "typeerror 3a unhashable type 3a 27list 27 python dictionary"
Sana
12 Oct 2019
1The error you gave is due to the fact that in python, dictionary keys must be immutable types (if key can change, there will be problems), and list is a mutable type.
2
3Your error says that you try to use a list as dictionary key, you'll have to change your list into tuples if you want to put them as keys in your dictionary.
4
5According to the python doc :
6
7The only types of values not acceptable as keys are values containing lists or dictionaries or other mutable types that are compared by value rather than by object identity, the reason being that the efficient implementation of dictionaries requires a key’s hash value to remain constant