Challenge 2: Yield Numbers From n Down to 0

Practice an exercise on generators to return all numbers from n to 0 in descending order.

Problem Statement

Implement a generator reverse(n) that returns All numbers from n down to 0.

Input

A number n

Output

All numbers from n down to 0.

Sample Input

8

Sample Output

8, 7, 6, 5, 4, 3, 2, 1, 0

Coding Exercise

Write your code below. It is recommended​ that you try solving the exercise yourself before viewing the solution.

Get hands-on with 1400+ tech skills courses.