Search⌘ K
AI Features

Introduction to Dictionaries

Explore how Python dictionaries store data as key-value pairs, emphasizing unique keys and value access. Learn different ways to access and iterate through dictionaries, including tracking indexes during loops. Gain foundational skills to manipulate dictionaries effectively in your Python programs.

What are dictionaries?

A dictionary is a collection of key-value pairs. Dictionaries are also known as maps or associative arrays.

A dictionary contains comma-separated key : value pairs enclosed within {}.

Python 3.8
d1 = { } # empty dictionary
d2 = {'A101' : 'Amol', 'A102' : 'Anil', 'B103' : 'Ravi'}
print(d1)
print(d2)

Note: In the code above, 'A101' ...