Access Nested Dictionary Data
Intermediate · Write the code · from Python Dictionaries: The Complete Guide with Real Examples
From the lesson: Python Dictionaries: The Complete Guide with Real Examples
Open the contacts app on your phone. You look up a person by name and get their phone number. You don't search by position - you don't say "give me contact number 47." You search by name.
Read the lessonA nested dictionary of students is given. Loop through each student and print their name and math score in this format:
Alice: 95
Bob: 82
Charlie: 91students = {
'Alice': {'math': 95, 'english': 88},
'Bob': {'math': 82, 'english': 90},
'Charlie': {'math': 91, 'english': 85},
}
# Loop and print each student's math score
More Dictionaries exercises
- Create a Dictionary and Access a ValueBeginner
- Add and Modify Dictionary EntriesBeginner
- Safe Access with get()Beginner
- Loop Through a DictionaryBeginner
- Predict the Output: Duplicate KeysBeginner
- Fix the Bug: Checking for a ValueIntermediate
- Build a Word CounterIntermediate
All Python exercises · 50 practice problems · Data Structures quiz