title: What is the difference between dict and collections.defaultdict?
body: <p>I was checking out Peter Norvig's <a href="http://norvig.com/spell-correct.html">code</a> on how to write simple spell checkers. At the beginning, he uses this code to insert words into a dictionary.</p>
  
  <pre><code>def train(features):
      model = collections.defaultdict(lambda: 1)
      for f in features:
          model[f] += 1
      return model
  </code></pre>
  
  <p>What is the difference between a Python dict and the one that was used here? In addition, what is the <code>lambda</code> for? I checked the API documentation <a href="http://docs.python.org/library/collections.html#collections.defaultdict">here</a> and it says that defaultdict is actually derived from dict but how does one decide which one to use?</p>