Assign the result of a loop to a variable in Python
<p>Consider a list I want to parse using a <code>for</code> :</p>

<pre><code>friends = ["Joe", "Zoe", "Brad", "Angelina", "Zuki", "Thandi", "Paris"]
for i in friends:
   print i
</code></pre>

<p>will return :</p>

<pre><code>"Joe", "Zoe", "Brad", "Angelina", "Zuki", "Thandi", "Paris"
</code></pre>

<p>However, if I want to put it to a (str) variable, like :</p>

<pre><code>friends = ["Joe", "Zoe", "Brad", "Angelina", "Zuki", "Thandi", "Paris"]
for i in friends:
    var=i
</code></pre>

<p>first I have to declare another <code>var</code> variable, which is silly but whatever.
then, </p>

<pre><code>print var
</code></pre>

<p>will return the last element of the list, which is "Paris", because the variable is overwritten for each iteration right.</p>

<p>So my question is : how can I assign the output of my loop "i", for each iteration, to a variable in Python ?</p>

<p>Sorry for the sillyness of this question but this is a concept I can't seem to figure out clearly.</p>