A route appears twice in a trip log. Follow the balance stored under each route as the loop progresses.
Predict the output
What total is printed for route B?
trips = [("B", 3), ("A", 8), ("B", 2)]
totals = {}
for route, km in trips:
totals[route] = totals.get(route, 0) + km
print(totals["B"])