31 out of 33 users completed this Bite ...
Will you be Pythonista #32 to crack this Bite?
Average Bite difficulty 1-10 rating: 4.33
» Up for a challenge? 💪
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 setthat gets passed into the class via its constructor. Complete the methods in the Promo class:
_pick_random_biteis a helper (
_here means private) that picks a randomly available Bite. When no more Bites are available raise a
new_biteshould 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!