title: How to add javascript to html using beautiful soup?
body: <p>I'm using beautiful soup to edit an html file. I've been able to add a  tag, but I'm having trouble adding my javascript code inside the script element. </p>
  
  <p>I have the following code: </p>
  
  <pre><code>soup = BeautifulSoup(differencehtml, 'html.parser')
  
  # create a new tag
  tag = soup.new_tag("script")
  tag.append = jscodestring  # this is not adding the javascript to the html file
  # tag.string = jscodestring # also tried this unsuccesfully
  
  head = soup.find('head')
  
  #insert new tag after head tag
  head.insert_after(tag)
  </code></pre>
  
  <p>When I inspect the resulting html, it looks like this:</p>
  
  <pre><code>...
  &lt;/head&gt;
  &lt;script&gt;
     &lt;/script&gt;
  ...
  </code></pre>
  
  <p>Why does append not work? How do I get code inside the script tag? </p>