We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 72. Retrieve the right Ninja Belt based on score

19 out of 20 users completed this Bite ...
Will you be Pythonista #20 to crack this Bite?
Average Bite difficulty 1-10 rating: 1.0
» You can do it! 😌

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!

Github login button