How do I access each element in list in for-loop operations?
<p>I am looping through this list and don't understand why <code>print(d)</code> returns each number in <code>seed</code> but assigning <code>i["seed"] = d</code> assigns the last element of <code>seed</code>.</p>

<p>How do I access each element in <code>seed</code> for operations other than <code>print()</code>?</p>

<pre><code>res = []
seed = [1, 2, 3, 4, 5, 6, 7, 8, 9]
i = {}
for d in seed:
    print(d)
    i["seed"] = d
    res.append(i)
print(res)
</code></pre>

<p>Thanks!</p>

<p>To answer your first question, it is because thew value of seed is being overwritten, as shown here:</p>

<pre><code>&gt;&gt;&gt; p = {'t':'H'}
&gt;&gt;&gt; p['t'] = 'k'
&gt;&gt;&gt; p
{'t': 'k'}
</code></pre>

<p>I am confused on your second part of the question. Elaborate more?</p>

python for-loop