Shouldn't this Python function return 6 all the time?
<p>I am new to Python and learning about functions. I came across the following function and at my wits end understanding how it works. It seems to me no matter the value of <code>b</code>, the answer should always be six but that isn't the case.</p>

<p><em><strong>CODE</em></strong></p>

<pre><code>def mult(a, b):
    if b == 0:
        return 0
    rest = mult(a, b - 1)
    value = a + rest
    return value
print "3 * 2 = ", mult(3, 2)
</code></pre>

<p>My understanding of what happens</p>

<ol>
<li>Since <code>b</code> is not 0 it proceeds</li>
<li><code>rest</code> is assigned the value <code>3, 1</code> and it runs the function again</li>
<li>Since <code>b</code> is 1 and does to equate to 0, it proceeds to <code>rest</code></li>
<li><code>rest</code> is assigned the value <code>3, 0</code> and it runs the function again</li>
<li>Since <code>b</code> is now zero it returns the value 0</li>
<li>It then proceeds to <code>value</code> which has the value 3 + 3 as <code>a</code> had the value of 3 and <code>rest</code> had the value of 3 i.e. <code>(3,0)</code></li>
<li>It returns the value 6</li>
</ol>

<p><strong>But</strong> if I assign <code>mult(3,4)</code>, it returns the value 12. Following my understanding, that isn't possible. Clearly, I am not understanding the logic flow. What am I doing wrong?</p>
