I am outputting an HTML file in Python. Inside the HTML, I have a table showing the keys and values from the dictionary in the Python file and I think I have to use a loop to display the table data in this case. But I'm confused about using python to output html content. I have tried using<% %> which is supposed to allow Python code in HTML but it didn't work..
message = """
<html>
<body>
<h1>Counting words</h1>
<table border = 1>
<tr>
<th>Words</th>
<th>Count</th>
</tr>
<% for key, value in wordDict.items(): %>
<% if value >= 10: %>
<tr>
<td><% print(key) %></td>
<td><% print(value) %></td>
</tr>
<% end %>
<% end %>
</table>
</body>
</html>"""
f.write(message)
f.close()