title: "object of type 'NoneType' has no len()" error
body: <p>I'm seeing weird behavior on this code:</p>
  
  <pre><code>images = dict(cover=[],second_row=[],additional_rows=[])
  
  for pic in pictures:
      if len(images['cover']) == 0:
          images['cover'] = pic.path_thumb_l
      elif len(images['second_row']) &lt; 3:
          images['second_row'].append(pic.path_thumb_m)
      else:
          images['additional_rows'].append(pic.path_thumb_s)
  </code></pre>
  
  <p>My web2py app gives me this error:</p>
  
  <blockquote>
  <pre><code>if len(images['cover']) == 0:
  TypeError: object of type 'NoneType' has no len()
  </code></pre>
  </blockquote>
  
  <p>I can't figure out what's wrong in this. Maybe some scope issue?</p>