← Back to challenges

Burglary Series (02): Most Valuable Item

PythonHardobjectsloopsarraysmath

Instructions

You call your spouse to inform his/her most precious item is gone! Given a dictionary of stolen items, return the most expensive item on the items.

Examples

most_expensive_item({
  "piano": 2000,
}) ➞ "piano"

most_expensive_item({
  "tv": 30,
  "skate": 20,
}) ➞ "tv"

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

Notes

  • There will only be one most valuable item (no ties).
  • The dictionary will always contain at least one item (no empty dictionary).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Move Zeroes