title: Python: Can we Loop inside a string?
body: <p>Like for example I have a string of HTML Ordered List. Inside that ordered list, I want to write n number of lists. How can I accomplish the task of adding the lists to this string?</p>
  
  <p>Here is the example code:</p>
  
  <pre><code>    html = """
      &lt;ol&gt;
        &lt;li&gt;
          &lt;!--Something--&gt;
        &lt;/li&gt;
        ... &lt;!--n lists--&gt;
        {}                   #str().format()
        &lt;li&gt;
          &lt;!--Something--&gt;
        &lt;/li&gt;
      &lt;/ol&gt;
      """
      for li in html_lists: #where li is &lt;li&gt;...&lt;/li&gt; and is inside the python list.
        html.format(li)
  </code></pre>
  
  <p>As far as I know, Strings are immutable and <code>.format()</code> will add <code>&lt;li&gt;</code> at <code>{}</code>. Hence this won't work for more than one <code>&lt;li&gt;</code>.</p>