← All practice pages
Python
Python Generators & Iterators
A generator produces values one at a time with yield instead of building a whole list in memory. That makes it well suited to long or endless sequences.
Try it now
Write a generator function "countdown(n)" that uses yield to produce the numbers from n down to 1.
Create a free account to run your answer and get ARIA's review.