recursion Think Python 2 exercise 5.5
<p>This question regarding exercise 5.5 from Think Python 2 has been <a href="https://stackoverflow.com/questions/21048933/understanding-recursion-in-python-2-think-python-exercise-5">asked and answered already</a>, but I still don't understand how this function works. Here's the function in question:</p>

<pre><code>def draw(t, length, n):
    if n == 0:
        return
    angle = 50
    t.fd(length*n)
    t.lt(angle)
    draw(t, length, n-1)
    t.rt(2*angle)
    draw(t, length, n-1)
    t.lt(angle)
    t.bk(length*n)
</code></pre>

<p>I see a recursive loop here:</p>

<pre><code>def draw(t, length, n):
    if n == 0:
        return
    angle = 50
    t.fd(length*n)
    t.lt(angle)
    draw(t, length, n-1)
</code></pre>

<p>After the function calls itself a sufficient number of times to cause n == 0, how does it move on to the next step, namely t.rt(2*angle)? Once n == 0, shouldn't the function return None and simply end? If not, where is returning to? The same thing happens again the next time it calls itself, and then the function continues to perform work long after the state n == 0 has been satisfied (twice!). I'm obviously missing a key concept here and would appreciate any light anyone can shed on this topic. Thanks in advance~</p>

<p>I've posted a picture explaining this in the following <a href="https://stackoverflow.com/questions/21048933/understanding-recursion-in-python-2-think-python-exercise-5/39974778#39974778">question</a> , for a fast navigation here's my picture : </p>

<p><a href="http://i.stack.imgur.com/rIfDL.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/rIfDL.jpg" alt="Explanation"></a></p>

python python-3.x recursion