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

As you have probably seen on the dashboard you can now gain Ninja Belts based on the amount of points (or Bitecoins) you gained solving Bites, ranging from white (10 points) to red (1000 points).

Complete the get_belt function below which receives a user_score, scores and belts.

Based on the user's score, the function should return the corresponding belt name.

For example with 162 points you would have the orange belt (not yet reached green = 175 points), 401 points gets you the brown belt, 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:

- Less than 10 there no belt in which case you have to return None.

- In case of more than 1000 points you have the highest belt (red).

Keep calm and code in Python!

Login and get coding
go back Intermediate level
Bitecoin 3X

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

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help