← Back to challenges

Burglary Series (01): Calculate Total Losses

PythonHardloopsdata_structures

Instructions

You just returned home to find your mansion has been robbed! Given a dictionary of the stolen items, return the total amount of the burglary (number). If nothing was robbed, return the string "Lucky you!".

Examples

calculate_losses({
  "tv" : 30,
  "skate" : 20,
  "stereo" : 50,
}) ➞ 100

calculate_losses({
  "painting" : 20000,
}) ➞ 20000

calculate_losses({}) ➞ "Lucky you!"

Notes

The item value is always positive.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Total Number of Unique Characters