Unit: Unit 6: Functions • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Recursive countdown demonstration
def countdown(n):
# 1. Base Case: stops the recursion when n reaches 0
if n == 0:
print("Blast off!")
return
# 2. Recursive Step: action + recursive call with smaller problem (n - 1)
print(f"T-minus {n}...")
countdown(n - 1)
print("Starting countdown:")
countdown(3)