Solution Review: Yield Numbers from n Down to 0
This lesson discusses how you can use Python generators to print a sequence starting from an integer n down to 0.
We'll cover the following
Solution:
In this problem, all you need to do is add a reverse loop that starts from n and goes to 0, with the value
being decremented by 1 in every iteration. Lines 5 and 6 simply print the numbers in the sequence n to 0.
Get hands-on with 1400+ tech skills courses.