GH avatar Bite 25. No promo twice, keep state in a class

In this bite a real world scenario: PyBites has a growing set of Bites and gives away promos. They choose a Bite randomly but don't want to choose the same one again.

Hence you are provided with a BITES constant (subset to keep it on the screen) and a bites_done set that gets passed into the class via its constructor. Complete the methods in the Promo class:

  1. _pick_random_bite is a helper (_ here means private) that picks a randomly available Bite. When no more Bites are available raise a NoBitesAvailable (provided).
  2. new_bite should use this helper and update self.bites_done (it keeps state, the reason we used a class here).

See also the tests. We hope you learn a thing or two. Enjoy!

59 out of 63 users completed this Bite.
Will you be Pythonista #60 to crack this Bite?
It takes an average of ~49 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 4.5 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Login and get coding
We use Python 3.7