Python dict keys must be hashable: Why lists don’t work

Python dict keys must be hashable: Why lists don't work

You can’t use a list as a Python dict key:

mylist = ['a', 'b']
d = {mylist: 10}   # TypeError!

Why not? Dicts run “hash” on a key to choose a pair’s storage location. To avoid pairs getting lost, mutable builtins (list, set, dict) cannot be used as dict keys.