title: 'NoneType' object has no attribute 'replace' in Python list comprehension
body: <p>I have the folllowing dictionary...</p>
  
  <pre><code>mydict = {'columns': ['col1', 'col2', 'col3'],
            'rows': [['col1', 'col2', 'col3'],
                     ['testing data 1', 'testing data 2lk\nIdrjy9dyj', 'testing data 3'],
                     ['testing data 2', 'testing data 3', 'testing data 4'],
                     ['testing data 3', 'testing data 4', 'testing data 5']]}
  </code></pre>
  
  <p>And I am using the following list comprehension to replace carriage return <code>"\n"</code> with this <code>"&lt;br&gt;"</code>. It works fine except when it gets passed an empty string  as it is reading a json file. Then it throws the error <code>'NoneType' object has no attribute 'replace'</code>. I just do not know how to put a <code>if is not none</code> statement in the list comprehension. Any help greatly appreciated..</p>
  
  <pre><code>for items in mydict['rows']:
          mydict['rows'][i] = [item.replace("\n","&lt;br&gt;") for item in items]
          i += 1
  </code></pre>