The Python dictionary is a built-in data type. It defines a one-to-one relationship between keys and values. Dictionaries contain a pair of keys and their corresponding values. It stores elements in key and value pairs. The keys are unique whereas values can be duplicate. The key accesses the dictionary elements.
Keys index dictionaries.
Let’s take an example.
The following example contains some keys Country Hero & Cartoon. Their corresponding values are India, Modi, and Rahul respectively.
>>> dict = {‘Country’: ‘India’, ‘Hero’: ‘Modi’, ‘Cartoon’: ‘Rahul’}
>>>print dict[Country]
India
>>>print dict[Hero]
Modi
>>>print dict[Cartoon]
Rahul