def recursion(x):
answer = 0
if( x > 10 ):
answer +=1
return recursion( x - 1)
return answer
recursion(15)
I'm just playing around with python and recursive functions and made this, but strangely having errors.
Why is this printing 0 instead of my expected answer of:
5
answeris a local variable. It is declared and set to zero each timerecursion()is called.