title: Python: How to insert a line in a multi-line string?
body: <p>I'm trying to make a simple website demo and I have some trouble editing the html using python. The following is the string I defined to store the html (not complete because it's too long). I want to write a function that will throw a error under a certain condition, but I don't know how to insert a line in the string "page".</p>
  
  <pre><code>page="""
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Sign up&lt;/title&gt;
      &lt;style type="text/css"&gt;
        .label {text-align: right}
        .error {color: red}
      &lt;/style&gt;
  
    &lt;/head&gt;
  
    &lt;body&gt;
      &lt;h2&gt;Sign up&lt;/h2&gt;
      &lt;form method="post"&gt;
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td class="label"&gt;
              Username
            &lt;/td&gt;
            &lt;td&gt;
              &lt;input type="text" name="username" value=""&gt;
            &lt;/td&gt;
            &lt;td class="error"&gt;
  
            &lt;/td&gt;
          &lt;/tr&gt;
  
          &lt;tr&gt;
            &lt;td class="label"&gt;
              Password
            &lt;/td&gt;
            &lt;td&gt;
              &lt;input type="password" name="password" value=""&gt;
            &lt;/td&gt;
            &lt;td class="error"&gt;
  
            &lt;/td&gt;
          &lt;/tr&gt;
  </code></pre>
  
  <p>I want to insert the line "There is an error" in the blank between these two lines:</p>
  
  <pre><code>&lt;td class="error"&gt;
  
  &lt;/td&gt;
  </code></pre>
  
  <p>Note there are two of this group in the string. How can I insert "There is an error" in the first group using Python? Thanks. </p>