Use the same field name to examine each record. Reading a field preserves the containing dictionary for later processing.
Read the titles in a list of shelf records.
shelf = [{"title": "Stone", "pages": 94}, {"title": "Moon", "pages": 80}]
for book in shelf:
print(book["title"])
# Stone
# MoonThe loop visits dictionaries in list order. Use one field to test whether a record belongs in the result and another field to supply its name.
Return the names of passengers whose line exactly matches the requested line. Every passenger record has name and line keys. Keep the input order.
riders = [{"name": "Lea", "line": "A"}, {"name": "Min", "line": "B"}]
rider_names(riders, "B") # ["Min"]