title: Creating new tag in python beautifulsoup
body: <p>I need to create new tags in an HTML file and add information to them. I wrote the following python code, following the example given in the beautifulsoup documentation, but it doesn't work. Where am I going wrong?</p>
  
  <pre><code>from bs4 import BeautifulSoup
  with open("content.htm") as insert:
      content = BeautifulSoup(insert, "html.parser")
  
      #Find the tag you wish to append to.
      original_tag = content.find("body")
  
      #Create &amp; append new tags.
      new_tag = content.new_tag("button", class="accordion")
      original_tag.append(new_tag)
  
      new_tag = content.new_tag("div", class="panel")
      original_tag.append(new_tag)
  
      new_tag = content.new_tag("p")
      original_tag.append(new_tag)
  
  print(content)
  </code></pre>
  
  <p>I wished to add the abovementioned 3 new tags between the: </p>
  
  <pre><code>&lt;body&gt;&lt;/body&gt;
  </code></pre>
  
  <p>part of the HTML document. It doesn't work. Where am I going wrong? The above classes, "accordion" and "panel" are added to the tags and used by another javascript program.</p>