How to change map into a loop?
<p>this question is probably really simple but it will help me to understand the difference between loop and map.
In the first example I managed to change it from:</p>

<pre><code>    nrs = list(map(lambda x: int( open("img_" + str(x) + ".csv").readline().split(",")[1] ) , range(82))
</code></pre>

<p>to:</p>

<pre><code>   nrs = [] 
   for x in range(82):
       nrs.append(int( open("img_" + str(x) + ".csv").readline().split(",")[1] ))
</code></pre>

<p>but how can I change:</p>

<pre><code>    plt.plot(list(map(lambda x: ages[x], list(avg_si.keys() ))), list(avg_si.values()), 'ro', label='size')
</code></pre>

<p>into a loop?
I tried with:</p>

<pre><code>srednia = []
for x in list(avg_si.values()):
     srednia.append(ages[x], list(avg_si.keys()))
plt.plot(srednia, "ro", label = "size")
</code></pre>

<p>But I get a KeyError </p>

<p>You should iterate over keys, not values.</p>

<pre><code>    srednia = []
    for x in list(avg_si.keys()):
        srednia.append(ages[x], list(avg_si.values()))
    plt.plot(srednia, "ro", label = "size")
</code></pre>

python