+ 8
Python - Dictionaries and keys
Why in a dictionary, key has to be an immutable?
2 odpowiedzi
+ 11
Because if a key is mutable its value could change.
http://effbot.org/pyfaq/why-must-dictionary-keys-be-immutable.htm
Thanks for your question and happy coding.
+ 1
python hashes the dictionary keys for sorting purposes. if you could change the keys the hashing algorithm could clash. i believe you can make lists of lists if you wanted to in python to get around this, but that would make working with your data slower. and theres more complex ways to get around it listed in the answers above.