I am trying to write a HTML file using python, and I want to print in .html a nested list.
I have written this, but I don´t have any idea about how to doit good.
words = [['Hi'], ['From'], ['Python']]
with open('mypage.html', 'w') as myFile:
myFile.write('<html>')
myFile.write('<body>')
myFile.write('<h1>---------------------------</h1>')
for i in range(len(words)):
myFile.write('<tr><td>'(words[i])'</td></tr>')
myFile.write('</body>')
myFile.write('</html>')
In .html I want to print the nested list in a table in this similar format:
<body>
<table>
<tr>
<td>Hi</td>
</tr>
<tr>
<td>From</td>
</tr>
<tr>
<td>Python</td>
</tr>
</table>
</body>
words = [['Hi', 'From', 'Python'], ['Goodbye', 'Java']]? If so, what should the output be?<table>and</table>. AndmyFile.write(print("\n".join(["<tr><td>{}</td></tr>".format(x[0]) for x in words])))