Add Up What You Can

Python for AIMedium+10 XP+10

Add Up What You Can

A market stall writes its prices down as text. A few were scribbled badly.

Write tally_prices(prices) that returns a dictionary with two keys:

  • "total": the sum of every price that int() can read
  • "skipped": a list of the prices it couldn't read, in their original order

If nothing can be read, the total is 0.

Examples

prices = ["12", "8", "free", "20"]
returns {'total': 40, 'skipped': ['free']}
prices = ["5", "5"]
returns {'total': 10, 'skipped': []}

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