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).
This commit is contained in:
committed by
Aditya Bhargava
parent
33a65829c0
commit
d7de908a82
@@ -1,10 +1,10 @@
|
||||
def countdown(i):
|
||||
print(i)
|
||||
# base case
|
||||
if i <= 0:
|
||||
return
|
||||
return 0
|
||||
# recursive case
|
||||
else:
|
||||
countdown(i-1)
|
||||
print(i)
|
||||
return countdown(i-1)
|
||||
|
||||
countdown(5)
|
||||
|
||||
Reference in New Issue
Block a user