Codington
0 of 6 problems solved • 0%

Exercise prompt

Group Riders by Stop

Sometimes a group needs all of its entries, rather than a single total. Give each new group its own empty list.

Example

Start two independent packing lists.

crates = {} crates.setdefault("fragile", []).append("cup") crates.setdefault("books", []).append("atlas") crates.setdefault("fragile", []).append("vase") print(crates) # {'fragile': ['cup', 'vase'], 'books': ['atlas']}

The first call for fragile creates its list. The second call for that key retrieves the existing list, so the cup stays there when the vase is added.

Your task

Complete boardings(riders). Each record supplies a stop and a name. Collect the names for every stop in arrival order, including repeated names. Empty input should return an empty dictionary.