>>> from jinja2 import Template
>>> template = Template("""
... <table style="border:2px black solid">
... <tr>
... {% for item in my_array %}
... <td>{{item}}</td>
... {% endfor %}
... </tr>
... </table>""")
>>> my_array = range(10)
>>> my_array
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> print(template.render(my_array=my_array))
<table style="border:2px black solid">
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</table>
>>>
С остальным - сами разберетесь, надеюсь?