Skip to main content

Python: Dictionary

It is a collection which is changeable and does not allow duplicates It is used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. 

Each key is separated from its value by a colon (:), the items are separated by commas, and the whole thing is enclosed in curly braces. Keys are unique within a dictionary while values may not be. Keys are case sensitive, same name but different cases of Key will be treated distinctly.

The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples and also unique.



Output: {1: 'apple', 2: 'papaya', 3: 'pineapple'}

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.