title: Python For Loops Returning Last Value | Explanation
body: <p>I have a simple problem which I've solved but it would be great if someone could explain <strong>why</strong> for loops do this in python and if there is a more elegant way. Really sorry if this is a dumb question - I have done my best to try multiple methods and look at related questions, but I still unsure why it doesn't work.</p>
  
  <p>I've read this post, but it doesn't quite explain my issue: <a href="https://stackoverflow.com/questions/9882209/for-loop-only-returning-the-last-word-in-a-list-of-many-words">for loop only returning the last word in a list of many words</a></p>
  
  <p>If I <strong>print</strong> x, it returns every month name perfectly.</p>
  
  <pre><code>monthName = []
  
  for i in df["Month_Number"]:
      x = calendar.month_abbr[i]
      print(x)
  </code></pre>
  
  <p>The below stores the result (month names) it in a nice clean list (which is great).</p>
  
  <pre><code>monthName = []
  
  for i in df["Month_Number"]:
      x = calendar.month_abbr[i]
      monthName.append(x)
  </code></pre>
  
  <p>I would then go on to solve my problem by doing this:</p>
  
  <pre><code>df["Month_Name"] = monthName
  </code></pre>
  
  <blockquote>
    <p>Why does the following ONLY return <strong>"NONE"</strong> when i integrate into the loop?</p>
  </blockquote>
  
  <pre><code>monthName = []
  
  for i in df["Month_Number"]:
      x = calendar.month_abbr[i]
      df["Month_Name"] = monthName.append(x)
  </code></pre>
  
  <blockquote>
    <p>Why does the following only return the <strong>last value</strong>:</p>
  </blockquote>
  
  <pre><code>for i in df["Month_Number"]:
      df["Month_Name"] = calendar.month_abbr[i]
  </code></pre>
  
  <p>I understand (to some degree) as to why append returns none, but was more interested in understanding why other approaches only return the LAST value.</p>