Loading section...

What Can Be a Key?

Dictionary keys must be immutable (unchangeable) types. This is because Python uses a special technique called hashing to make key lookups extremely fast. Immutable types can be hashed; mutable types cannot. Keys Must Be Unique Each key in a dictionary must be unique. If you create a dictionary with duplicate keys, only the last value is kept: