title: Python Add to dictionary loop
body: <p>This function is supposed to add a name and number to the dictionary 'phoneBook' when I run the loop, but for some reason I can't get it to work. Any ideas on why not? Thanks a lot!</p>
  
  <pre><code> phoneBook = dict()
      def addNumber(name, number):
          for i in phoneBook:
              if i == name:
                  print 'error'
              else:
                  phoneBook[name] = number
  </code></pre>