Codington
0 of 6 problems solved • 0%

Exercise prompt

Total Delivery Units

A CSV reader returns strings even when a cell contains a number. Convert a count with int() before adding it.

Example

A visitor count arrives as text. Convert it before comparing quantities.

import csv from io import StringIO rows = csv.DictReader(StringIO("room,count\nA,2\nB,11")) large_rooms = [row["room"] for row in rows if int(row["count"]) >= 10] print(large_rooms) # ['B']

The conversion makes 11 a number. The delivery task also needs a running total for each named group.

Your task

Implement delivery_totals(text). Read the depot and units columns and return a dictionary of total units per depot. Every units cell contains an integer.

delivery_totals("depot,units\nNorth,3\nNorth,12\n") # {"North": 15}