easy +5 pts

Countdown printer

Create a function that prints a countdown from n to 1 and returns 'Go!'

Write a function `countdown(n)` that prints each integer from `n` down to `1` inclusive, one per line, and then returns the string `"Go!"`. For example, calling `countdown(3)` should print `3`, `2`, `1` on separate lines and then return `"Go!"`. If `n` is less than or equal to 0, the function should print nothing and just return `"Go!"`.

Constraints

- `n` is an integer (may be negative or zero) - Time complexity: O(n) - Space complexity: O(1)

Example

>>> countdown(3)
3
2
1
'Go!'
>>> countdown(1)
1
'Go!'
>>> countdown(0)
'Go!'
5 points ~5 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use a `for` loop with `range(n, 0, -1)` to iterate from n down to 1.
Print each number inside the loop, then return 'Go!' after the loop.
What happens if n is negative or zero? The range will be empty automatically.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.