𝐍ðĻ𝐭 𝐄ðŊ𝐞ðŦðēð­ðĄðĒ𝐧𝐠 𝐂𝐚𝐧 𝐁𝐞 𝐚 𝐊𝐞ðē ðĒ𝐧 𝐏ðēð­ðĄðĻ𝐧'𝐎 𝐃ðĒ𝐜𝐭ðĒðĻ𝐧𝐚ðŦðē

I have seen quite a few candidates trying to use a list as a key for their dictionaries.

Mutable objects such as lists, sets and dictionaries are not hashable and therefore cannot be used as dictionary keys.

When you insert a key-value pair, Python computes the hash of the key to determine where to store the value. If the key's content changes after insertion, its hash value changes, and Python can't locate the key in the dictionary anymore.

No need to memorize specific types. Focus on the principle: if an object is immutable and hashable, it can be a dictionary key.

I wrote about the reason and how to work around this limitation in my blog if you are curious: https://blog.faangshui.com/p/not-all-keys-fit-pythons-dictionary