num=0
def add(n):
    global num
    num+=n
    if n==0:
        return num
    else:
        return add(n-1)
print(add(10000))
My understanding is that for each function call, it returns another function (recursion) and the function which calls "dies" because it has "return"ed something. So there shouldn't be a problem of stack overflow.
But clearly I'm wrong. Where am I wrong?
output if n==0: RecursionError: maximum recursion depth exceeded in comparison
Thank u!
P.S. I know i'd be better off looping for this problem but i just want to understand the concept.
 
     
     
     
    