Codington
0 of 6 problems solved • 0%

Exercise prompt

Read a Manifest

Use the same field name to examine each record. Reading a field preserves the containing dictionary for later processing.

Example

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 # Moon

The 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.

Your task

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"]