← Back to challenges

Burglary Series (05): Third Most Expensive

PythonHardobjectsarraysloops

Instructions

Time to call your lover to inform him/her what he/she lost in the burglary.

Given a dictionary of the stolen objects, return the 3rd most expensive item on the list. If that is not possible, because there are not enough items, return False.

Examples

third_most_expensive({}) ➞ False
# Items are less than three.

third_most_expensive({"piano": 100, "stereo": 200 }) ➞ False
# Items are less than three.

third_most_expensive({"piano": 100, "stereo": 200, "tv": 10, "timmy": 500 }) ➞  "piano"
# 'piano' is the third most expensive item.

Notes

All prices will be of different monetary values.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.