Login and get codingWrite a simple generator that counts from 100 to 1. It can just return the
int
s one by one, no fancy formatting, just focus on the basic mechanics of generators. Remember that going beyond1
it would trigger aStopIteration
exception.Here is how it works:
>>> from countdown import countdown >>> cd = countdown() >>> next(cd) 100 >>> next(cd) 99 >>> next(cd) 98 >>> next(cd) 97 ... ... 95 calls more ... >>> next(cd) 1 >>> next(cd) Traceback (most recent call last): File "", line 1, in StopIterationGood luck, have fun and keep it Python!
330 out of 336 users completed this Bite.
Will you be the 331st person to crack this Bite?
Resolution time: ~20 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 1.91 on a 1-10 difficulty scale.
» You can do it! 😌