I have a working code and it is fully functional. However, I do not understand WHY it works the way it does and it would be most awesome if you guys could explain it to me.
What I understand is that each recursion will be in the stack until the function is terminated, so the results of each calculation are kept. What I don't understand is why a simple return [] will actually return the result of each recursion.
def reverse(li):
if not li:
return []
else:
return reverse(li[1:]) + [li[0]]