Skip to content
dreamcode
dreamcode
Map
Dict Diver
Section challenge · BeginnerPython
Reward: +40 XP
PROBLEM

Dict Diver

Given a dictionary mapping star names to their magnitude values, write a function find_brightest(stars) that returns the name of the brightest star (the one with the lowest magnitude). If the dictionary is empty, return None.

Examples
find_brightest({'Vega': 0.03, 'Sirius': -1.46, 'Betelgeuse': 0.5})
'Sirius'
find_brightest({})
None
solution.py
PYTHON
Saved as you type

Tests

0 of 3 passing
  • multiple stars → Sirius
    find_brightest({'Vega': 0.03, 'Sirius': -1.46, 'Betelgeuse': 0.5})
    expected 'Sirius'
  • empty dict → None
    find_brightest({})
    expected None
  • single star → Polaris
    find_brightest({'Polaris': 1.97})
    expected 'Polaris'
On the line
+40 XP
Pass all 3 tests to claim it.