How argument with return statement calling function?
<p>I am trying to understand a program how this return is calling function and how we are passing argument in function with return ?</p>

<p>program is :</p>

<pre><code>def hello(x,b):
    z=x+b
    print(z)
    return "hi"


def hi(n):
    return hello(4,4)
for i in range(3):
    print(hi(3))
</code></pre>

<p>i am confuse how return hello(4,4) calling main function? can we pass argument in function with return ??</p>

<p>if we pass argument in function with return then i tried something like this but its giving error :</p>

<pre><code>def hello(x,b):
    z=x+b
    print(z)


    return hello(4, 4)
</code></pre>

<p>but its not working , I know i am not calling function but i did with return hello(4,4) why its not working when same working in previous program? Please explain </p>

<pre><code>def hello(x,b):
    z=x+b
    print(z)


    return hello(4, 4)
</code></pre>

<p>does not work because of infinite recursion. Essentially this function is making an infinite loop.</p>

<p>To see how this works, look at how you would write it out in code:</p>

<pre><code>x = 4
b = 4
z = x+b
print(z)
#And then we are running the function again.
x = 4
b = 4
z=x+b
print(z)
#And again.
x = 4
b = 4
z=x+b
print(z)
#And again.
x = 4
b = 4
z=x+b
print(z)
</code></pre>

<p>You get the idea. But when we call it with a different function, the code looks like this:</p>

<pre><code>for i in range(3):
    x = 4
    b = 4
    z=x+b
    print(z)
</code></pre>

<p>And then the function does not run again because there are no more calls to it.</p>

<p>See <a href="http://www.python-course.eu/course.php" rel="nofollow">http://www.python-course.eu/course.php</a> and <a href="http://openbookproject.net/thinkcs/python/english3e/recursion.html" rel="nofollow">http://openbookproject.net/thinkcs/python/english3e/recursion.html</a> for more information.</p>

python python-2.7 function python-3.x return