Totals Both Ways

Data with PythonEasy+10 XP+10

Totals Both Ways

A bakery records how many of each item it sells. The numbers come as a grid: one row per day and one column per item.

The owner asks two questions: how many things were sold each day, and how many of each item were sold over all the days?

Task: write totals(sales) and return a dict:

  • "per_day" — the total sold on each day, as a plain list in day order,
  • "per_item" — the total sold of each item, as a plain list in item order.

The grid always has at least one day and one item.

Examples

sales = [[12, 30, 8], [15, 25, 10]]
returns {'per_day': [50, 50], 'per_item': [27, 55, 18]}
sales = [[5, 7], [3, 9], [6, 4], [8, 2]]
returns {'per_day': [12, 12, 10, 10], 'per_item': [22, 22]}

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run