I have a Python script that uses smtplib
, email.mime.multipart
, and email.mime.text
to send an email with a numbered list. After the list exceeds 99 it inserts tabs after the number and messes up the formatting.
The only thing that has worked so far has been inserting a line break after each number to keep formatting consistent, but it doesn't look as good.
for i in range(0:200):
body_row = '<li>First line here <br>Second line here</li>'
body_total += body_row
body_total = "Total List" + "<ol>" + body_total + "</ol>" + "<br>"
The output looks like this:
99. First line here
Second line here
100. First line here
Second line here
101. First line here
Second line here
Does anyone know of an easy way to fix this other than my line break solution?
Your question has little do with Python programming, as it is primarily about how to format something in HTML.
I think the answer is to use the HTML <ol>
ordered list tag, which will do what you want (and you don't have to explicitly number the elements yourself).
<ol>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
<li>
First line here<br />
Second line here
</li>
.
.
.
</ol>
Result rendered by a web browser: