Files
grokking_algorithms/03_recursion/python/01_countdown.py
Maria Kovaleva d7de908a82 Fix countdown.py returning None (#94)
The original code does not return the value in the if-clause and the return statement in the else-clause, which led to the function returning None at the end of the countdown (5, 4, 3, 2, 1, 0, None).
2018-12-28 08:25:48 -08:00

11 lines
138 B
Python

def countdown(i):
# base case
if i <= 0:
return 0
# recursive case
else:
print(i)
return countdown(i-1)
countdown(5)