☆ Iteration + Recursion HW
recursion
favorite_songs = ["Pasture Child", "Into It", "Orange Soda", "Thinkin Bout You", "Denver", "Blame on Me", "Phone Numbers", "Keep Driving"]
def list_favorite_songs(songs, index):
if index == len(songs):
return
print(songs[index])
list_favorite_songs(songs, index + 1)
list_favorite_songs(favorite_songs, 0)
Pasture Child
Into It
Orange Soda
Thinkin Bout You
Denver
Blame on Me
Phone Numbers
Keep Driving
fibonnaci sequence program
The base cases are needed to stop the recursion and define the values for f(0) as well as f(1), which are important in order to continue the sequence. Without them, the sequence would not be able to be repeated infintitely.