aspects_of_life = ["family", "school", "hobbies", "friends", "work"]
def output_aspects(aspects, index):
# Base Case
if index >= len(aspects):
return
# Recursive Case
print(aspects[index])
output_aspects(aspects, index + 1)
# Call the recursive function with the initial index 0
output_aspects(aspects_of_life, 0)
def fibonacci(x):
if x == 1:
return 0 #First terminating statement
if x == 2:
return 1 #Second terminating statement
else:
# Calculates the sum of two proceeding numbers
# Without it recursion would continue infinitely
return fibonacci(x - 1) + fibonacci(x - 2)
# Print Fibonacci numbers from 1 to 10
for i in range(10):
print(fibonacci(i + 1))
0
1
1
2
3
5
8
13
21
34