I have
fruits = [ "apple" , "pineapple" , "banana", "oranges"]
sizes = ["small", "medium", "large"]
I want to create a HTML home page.
for this I am currently doing this:
import os
def home_html(func)
htmlFile = open('home_fruits.html', 'w')
message = """<DOCType html>
<html>
<head>
<title> Classification of fruits </title>
</head>
<body> <h1> Fruits-Home Page </h1>
<style type = "text/css">
style code for the table
</style>
<table class = "tg">
<tr>
<th class="tg-031e">apple</th>
<th class="tg-031e">banana</th>
<th class="tg-031e">pineapple</th>
<th class="tg-031e">oranges</th>
</tr>
<tr>
<td class="tg-031e"><a href = "apple_details.html"</th> Details for apple </a></td>
similarly for pineapple
similarly for banana
similarly for oranges
</tr>
</table>
</body>
</html>"""
htmlFile.write(message)
htmlFile.close()
Similarly I create each individual HTML pages like apple_details.html etc. All hardcoding.
Is there some easy way to do this? like instead of
<th class="tg-031e">apple</th>
<td class="tg-031e"><a href = "apple_details.html"</th>
if I do
<th class="tg-031e">fruit</th>
<td class="tg-031e"><a href = "fruit_details.html"</th>
should create automatic table for all the fruits?
The question is not duplicate, it is not asking for template generation. I want to reduce hardcoding.