Use function to update calculations
<p>I created a function which updates the single list by adding the interest rate.</p>

<pre><code>def first(lst, rate):
    for i in range(len(lst)):
        lst[i] += lst[i] * rate[i]
</code></pre>

<p>My question is, how to use this function to update two dimensional list by adding the interest rate?</p>

<p>For example:</p>

<pre><code>lst2 = [[25, 10, 300], [7, 30, 80], [7, 530, 24],[65, 30, 2]]
rate = [0.5, 0.02, 0.15]

&gt;&gt;&gt; for i in lst2:
        print(i)

[37.5, 10.2, 345.0]
[10.5, 30.6, 92.0]
[10.5, 540.6, 27.6]
[97.5, 30.6, 2.3]
</code></pre>

<p>My code:</p>

<pre><code>def second(lst2, rate):
    for x in lst2:
        for y in x:
            lst2[x][y] += first(lst2[x][y],rate[x])
</code></pre>

<p>Any help will be much appreciated.
Thanks</p>
