Bite 85. Write an advanced property

After Bite 19. Write a simple property let's write a more advanced one.

In this Bite you are presented with a NinjaBelt class that keeps track of scores and Ninja Belts earned (a very real scenario). Some setup code has been provided like the _score and _last_earned_belt variables and the getter and setter methods that make up the property.

The goal is to write a property called score that does the following:

  1. Make sure it can only be assigned an integer,
  2. It can not be assigned a score lower than the current score,
  3. It checks in BELTS if a new belt was earned (for example going from 49 to 50 you earn the yellow belt), if so it stores it in self._last_earned_belt.
  4. For each new score print a message:
    • If a new badge was earned: Congrats, you earned {score} points obtaining the PyBites Ninja {rank} Belt
    • Else just the new score: Set new score to {score}

See the TESTS tab for more info. Good luck, have fun and keep calm and code in Python!

16 out of 17 users completed this Bite.
Will you be Pythonista #17 to crack this Bite?
Average Bite difficulty 1-10 rating: 6.0
» Up for a challenge? 💪

Github login button
We use Python 3.7