I have trouble understanding stack frames for recursive functions. Not sure if this is the right place to ask but I have tried finding examples and I still don't understand it. For example I have this recursive function for a list:
def printout(list):
if len(list) > 0:
print(list[0])
printout(list[1:])
And list1 = [5,6,7,8,9]
The printout would look something like this:
5 6 7 8 9
Then if I change the places of "print(list[0])"
and "printout(list[1:])"
like this:
def printout(list):
if len(list) > 0:
printout(list[1:])
print(list[0])
The printout would then be the other way around:
9 8 7 6 5
Why is that and how would the Stack frames look for both functions? Thankful for any help!