+ 2

Dictionary

Why are variables inside dictionaries immutable???

16th Jun 2018, 2:46 PM
Emmanuel Boruett
Emmanuel Boruett - avatar
1 Odpowiedź
+ 4
If you use a variable as a key for a dictionary, the value of the variable is taken for it; if you change the variable afterwards, it has no relation to the key anymore. (If you try to take a list as a key, you get an error message.) The key is meant to be a 'name' for the content on the right side. If the name could change, you couldn't access the content in your dictionary any longer. Imagine the names in your phone book changing while you're not looking! ;-)
16th Jun 2018, 3:42 PM
HonFu
HonFu - avatar