Editor

Predict the Output: Nested Dict Access

Beginner · Predict the output · from Working with Nested Lists, Dicts, and Complex Data Structures

From the lesson: Working with Nested Lists, Dicts, and Complex Data Structures

Think about a school. A school has classrooms. Each classroom has students. Each student has a name, an age, and a list of grades. That's data inside data inside data - nested data.

Read the lesson

Read the code carefully. What will it print? Type the exact output.

data = {
'user': {
'name': 'Alice',
'scores': [80, 90, 100],
},
}
print(data['user']['name'])
print(data['user']['scores'][2])

More nested data exercises

All Python exercises · 50 practice problems · Data Structures quiz