avatar Bite 214. A countdown generator

Write a simple generator that counts from 100 to 1. It can just return the ints one by one, no fancy formatting, just focus on the basic mechanics of generators. Remember that going beyond 1 it would trigger a StopIteration exception.

Here is how it works:

>>> from countdown import countdown
>>> cd = countdown()
>>> next(cd)
>>> next(cd)
>>> next(cd)
>>> next(cd)
... 95 calls more
>>> next(cd)
>>> next(cd)
Traceback (most recent call last):
  File "", line 1, in 

Good luck, have fun and keep it Python!

Login and get coding
go back Beginner level
Bitecoin 2X

321 out of 327 users completed this Bite.
Will you be Pythonista #322 to crack this Bite?
Resolution time: ~20 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 1.91 on a 1-10 difficulty scale.
» You can do it! 😌

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

Ask for Help