Introduction to Dictionaries
Learn about the usage of dictionaries in Python.
We'll cover the following...
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 {}
.
Press + to interact
d1 = { } # empty dictionaryd2 = {'A101' : 'Amol', 'A102' : 'Anil', 'B103' : 'Ravi'}print(d1)print(d2)
Note: In the code above,
'A101'
...