title: How do I create add new items to a dictionary while in a loop?
body: <p>I'm writing a program that reads names and statistics related to those names from a file. Each line of the file is another person and their stats. For each person, I'd like to make their last name a key and everything else linked to that key in the dictionary. The program first stores data from the file in an array and then I'm trying to get those array elements into the dictionary, but I'm not sure how to do that. Plus I'm not sure if each time the for loop iterates, it will overwrite the previous contents of the dictionary. Here's the code I'm using to attempt this:</p>
  
  <pre><code>f = open("people.in", "r")
  
  tmp = None
  people
  
  l = f.readline()
  while l:
          tmp  = l.split(',')
          print tmp
          people = {tmp[2] : tmp[0])
          l = f.readline()
  
  people['Smith']
  </code></pre>
  
  <p>The error I'm currently getting is that the syntax is incorrect, however I have no idea how to transfer the array elements into the dictionary other than like this. </p>