Skip to content
← Python for AI/ML · all 50 levels

Nested data

Level 29 of 50 · Data structures

Level 29 of 50

Nested data

explained with family records. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaAmmi wants every cousin's name AND age, all in one list!
TeacherEasy! Put dictionaries inside a list. That's nested data!
family.py
fam = [
  {"name": "Ali", "age": 9},
  {"name": "Zara", "age": 12},
]
print(fam[1]["name"])
TeacherOne list, holding two dictionaries. Let's grab Zara's name!
SanaTWO brackets, back to back?
TeacherRead left to right! [1] picks Zara's dict. Then ["name"] picks her name!

⏸ Pause & predict: what prints?

ride = {
  "driver": "Usman",
  "stops": ["DHA", "Saddar"],
}
print(ride["stops"][1])

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.