Python returns nothing after recursive call
<p>I am working on a python script that calculates an individual's tax based on their income.</p>

<p>The system of taxation requires that people are taxed based on how rich they are or how much they earn.</p>

<p>The first <strong>1000</strong> is not taxed,<br>
The next <strong>9000</strong>  is taxed 10%
The next <strong>10200</strong> is taxed 15% 
The next <strong>10550</strong> is taxed 20%
The next <strong>19250</strong> is taxed 25%<br>
Anything left after the above is taxed at 30%</p>

<p>I have the code running and working and I am able to get the code working to follow the conditions above using recursion.</p>

<p>However, I have a problem returning the total_tax for the which should be the return value of the function.</p>

<p>For example, an income of <strong>20500</strong> should be taxed <strong>2490.0</strong>.</p>

<p>Here is my code snippet below:</p>

<pre><code>def get_tax(income, current_level=0, total_tax=0,):
    level = [0, 0.1, 0.15, 0.2, 0.25, 0.3]
    amount = [1000, 9000, 10200, 10550, 19250, income]

    if income &gt; 0 and current_level &lt;=5:
        if income &lt; amount[current_level]:
            this_tax = ( income * level[current_level] )
            income -= income

        else:    
            this_tax = ( level[current_level] * amount[current_level] )
            income -= amount[current_level]
            current_level += 1

        total_tax += this_tax
        print total_tax    
        get_tax(income, current_level, total_tax)

    else:
        final =  total_tax
        return final

get_tax(20500)
</code></pre>

<p>As you can see from the snippet, it does not work when I put the return statement in an else block, I have also tried doing it without the else block but it still does not work.</p>

<p>Here is a link to the snippet on <a href="https://repl.it/D8si/1" rel="nofollow">Repl.it</a></p>

<p>It's returning nothing because you're not <code>return</code>ing.</p>

<p><code>return get_tax(income, current_level, total_tax)</code>.</p>

<p>Now that it's returning something, you need to do something with the returned value. </p>

python recursion return-value