← Back to challenges

Generate a Countdown of Numbers in a List

PythonHardarraysloops

Instructions

Create a function that takes a number as an argument and returns a list of numbers counting down from this number to zero.

Examples

countdown(5) ➞ [5, 4, 3, 2, 1, 0]

countdown(1) ➞ [1, 0]

countdown(0) ➞ [0]

Notes

The argument will always be greater than or equal to zero.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Unlucky 13