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>Curly braces <code>{}</code> in python represent <a href="http://www.tutorialspoint.com/python/python_dictionary.htm" rel="nofollow">dictionaries</a> which works based on a key and value. Each time you iterate through your loop you overwrite the key: 'seed' with the current value of the list seed. So by the time the loop ends the last value of the list seed is the current value of seed in the dictionary i.</p>

python for-loop