Created
March 10, 2016 09:57
-
-
Save ntijoh-daniel-berg/013e60d0e24c7270e855 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countdown(start): | |
""" creates a list of numbers from start to zero | |
:param start: (int) the starting value | |
:return: the list of numbers | |
:rtype: list | |
:raises ValueError: if start is less than 1 | |
Example: | |
countdown(start=3) >>> [3, 2, 1 0] | |
""" | |
if start < 1: | |
raise ValueError('start must not be less than 1') | |
current = start | |
numbers = [] | |
while current >= 0: | |
numbers.append(current) | |
current -= 1 | |
return numbers | |
countdown(start=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment