COLLECTIONSChapter 5 · Collections
Nested data
Real data is nested: a list of dictionaries (like rows in a table), or a dictionary whose values are lists. Read it one level at a time: stars[0] is the first dictionary, and stars[0]["name"] is its name. Loop over the outer list, then use keys on each item.
Worked example
How it reads
- Each index or key goes one level deeper:
stars[0]["tags"][1] - Loop over the outer list; each
staris a whole dictionary inworks on the inner list too:"bright" in star["tags"]

Cloud tip: Lost in nested data? Print one level at a time:
print(stars[0]), then print(stars[0]["tags"]).

