avatar Bite 72. Retrieve the right Ninja Belt based on score

As you have probably seen on the new dashboard you can now gain Ninja Belts based on the amount of points (or Bitecoins) you gained solving Bites:

from pprint import pprint as pp

{10: 'white',
 50: 'yellow',
 100: 'orange',
 175: 'green',
 250: 'blue',
 400: 'brown',
 600: 'black',
 800: 'paneled',
 1000: 'red'}

Complete the get_belt function below which receives a user_score which you can assume to be an int.

The function should return the corresponding belt name from the HONORS dict. For example with 162 points you would have the orange belt (not yet reached green), 401 = brown, 999 is paneled, etc.

Note that the scores are inclusive so if you have 10 points you have earned the white belt, ≥ 50 = yellow belt, etc. Also make sure you take the min and max boundaries into account (< 10 is no belt and > 1000 is the highest belt).

Is there a stdlib module that could be useful here? Have fun!

Login and get coding
go back Intermediate level
Bitecoin 3X

196 out of 196 users completed this Bite.
Will you be Pythonista #197 to crack this Bite?
Resolution time: ~41 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 4.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8