A Simple Generator

Lab Python Intermediate 20 points

Write a generator countdown(n) that yields n, n-1, …, 1. Print its values on one line.

Input

One integer.

Output

One line.

Example

Input

5

Output

5 4 3 2 1
Sample input available Sample output available
Editor
Python

Hints

yield produces a value and pauses the function until the next value is requested.

Solution explanation

Generators produce values lazily, one at a time, without building a list.

Show solution
def countdown(n):
    while n > 0:
        yield n
        n -= 1


print(*countdown(int(input())))
Output
Answer
HOME LEARN COMMUNITY DASHBOARD