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?
Here is the example code:
html = """
<ol>
<li>
<!--Something-->
</li>
... <!--n lists-->
{} #str().format()
<li>
<!--Something-->
</li>
</ol>
"""
for li in html_lists: #where li is <li>...</li> and is inside the python list.
html.format(li)
As far as I know, Strings are immutable and .format() will add <li> at {}. Hence this won't work for more than one <li>.
html.format('\n'.join(html_lists))?