Thanks, it worked. Now I am trying to understand why it does. Is it because the first time it executes function(), there is no return statement so it finishes executing the function and returns the default return value of None?
You just have to look at the code: When you call the function what is the argument that is passed in? You can think of each invocation (whether called from 'outside' or from 'inside') as a distinct function. This is the function:
func(5) returns func(4)
func(4) returns func(3)
func(3) returns func(2)
func(2) returns func(1)
func(1) returns func(0)
func(0) ... takes the other branch of the depth test ... returns 10
So, you can see that for this function, you always get 10 no matter what non-negative argument you pass in. (Beware passing a negative argument though: What will happen?).
More interesting recursive functions do something that is ... more interesting. For instance one of the canonical recursive functions is factorial:
assert num == int(num)
except (AssertionError, ValueError):
print ("You must pass an integer parameter")
if num < 0:
return 0 - factorial(-num)
# We know num >= 0 here
if num <= 1:
return num * factorial(num-1)
print ("%d: %d"%(3,factorial(3)))
print ("%d: %d"%(-4,factorial(-4)))
print ("%s: %s"%("moo",factorial("moo")))
print ("%s: %s"%(1.5,factorial(1.5)))
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...