Skip to content

Instantly share code, notes, and snippets.

@ntijoh-daniel-berg
Created March 10, 2016 09:57
Show Gist options
  • Save ntijoh-daniel-berg/013e60d0e24c7270e855 to your computer and use it in GitHub Desktop.
Save ntijoh-daniel-berg/013e60d0e24c7270e855 to your computer and use it in GitHub Desktop.
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