A dictionary connects a key to a value
A dictionary is a collection of labelled entries. Each entry has a KEY, which tells us what to look for, and a VALUE, which is the information stored there. Think of a labelled drawer: give its label and get what is inside. You do not need to walk through all earlier drawers.

Write a colon between each key and its value, and curly braces around the dictionary: {7:76, 21:74}. The key 7 identifies Aditya; the value 76 is Aditya’s Chemistry mark. Monika has CardNo 21 and Chemistry 74. A key need not be a student ID: city names, customers, birthdays and train numbers are useful keys too.
| Question | Key | Value |
|---|---|---|
| What is this student’s mark? | CardNo | Mark |
| How many students are from this city? | City | Count |
| Who has this birthday? | Day + month | List of IDs |
| Where does this historical train start? | Train number string | Source station |
Try it yourself
In {7:76,21:74}, what are the keys?
Show explained answer
7 and 21. The values are 76 and 74.
Try it yourself
Can a dictionary value be a list?
Show explained answer
Yes. A value can be a number, Boolean, string, list or another dictionary, depending on the problem.
Try it yourself
Is a dictionary just a list of student IDs?
Show explained answer
No. Its entries connect each unique key to a value. A list is an ordered sequence of elements.
