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).
11 lines
138 B
Python
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)
|