title: dictionary key error python
body: <p>I get the error "Key Error: 'tempMax'".</p>
  
  <p>Can anyone tell what the problem is with the following code:</p>
  
  <pre><code>def catagorise(self, day, cat, f):
      self.features.setdefault(cat, {f:{'high':0,'mid':0,'low':0}})
  
      if f == 'tempMean':
          if day.tempMean &gt; 15.0:
              self.features[cat][f]['high'] += 1
          elif day.tempMean &gt; 8.0 and day.tempMean &lt; 15.0:
              self.features[cat][f]['mid'] += 1
          elif day.tempMean &lt;= 8.0:
              self.features[cat][f]['low'] += 1       
  
      if f == 'tempMax':
          if day.tempMax &gt; 15.0:
              self.features[cat][f]['high'] += 1
          elif day.tempMax &gt; 8.0 and day.tempMax &lt; 15.0:
              self.features[cat][f]['mid'] += 1
          elif day.tempMax &lt;= 8.0:
              self.features[cat][f]['low'] += 1   
  </code></pre>
  
  <p>A day is an object which has variables such as mean temperature, max temperature etc. Cat is the category which it will be put into e.g 'Fog', 'Rain', 'Snow', 'None' and f is the feature to check e.g. 'tempMax'</p>
  
  <p>The features dictionary is defined when the class is created.   </p>