title: AttributeError: 'NoneType' object has no attribute 'replace_with'
body: <p>I am getting the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "2.py", line 22, in &lt;module&gt;
      i.string.replace_with(i.string.replace(u'\xa0', '-'))
  AttributeError: 'NoneType' object has no attribute 'replace_with'
  </code></pre>
  
  <p>Some of the code</p>
  
  <pre><code>soup = bs4(open("test.html")) 
  
  table = soup.find("table", {"color":"#fff"})
  
  for i in soup.find_all('small'):
      i.string.replace_with(i.string.replace(u'\xa0', '-'))  &lt;--Line 22
  </code></pre>
  
  <p>It was working yesterday, but I had to reinstall Mint on another VM and I can't get that to work again. How can I fix that?</p>
  
  <p>EDIT: This is all the code:</p>
  
  <pre><code>from bs4 import BeautifulSoup as bs4
  
  soup = bs4(open("test.html")) 
  
  table = soup.find("table", {"color":"#fff"})
  
  for i in soup.find_all('small'):
      i.string.replace_with(i.string.replace(u'\xa0', '-'))
  
  #print soup
  f = open("new.html", "w")
  f.write(str(table))
  </code></pre>
  
  <p>This is the table in test.html:</p>
  
  <pre><code>&lt;table color="#fff"&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;small&gt;&lt;small&gt;&amp;nbsp;&lt;/small&gt;&lt;/small&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  </code></pre>