Skip to main content

Python: Properties of Dictionary Keys

There are two important points while using dictionary keys. 

1. More than one entry per key is not allowed ( no duplicate key is allowed).

dict_1 = {1:'a',2:'b',1:'c',4:'d'}

Output: c

2. The values in the dictionary can be of any type, while the keys must be immutable like numbers, tuples, or strings ,and keys are also case sensitive.

dict_1 = {[1]:'a',2:'b',3:'c'}

Output: TypeError: unhashable type: 'list'

Submitted by devanshi.srivastava on June 24, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.