#!/usr/bin/python3
###################################################################################
# print a 2 dimensional loop in an html table 
###################################################################################
print("Content-Type: text/html \n")  #http header with newline char (required for web)


print("<html>")
print("<body>")
print("<h2>A Dynamic 2 Dimensional Table Using a Nested Loop</h2> ")

print("<table border=1>")

print("<tr bgcolor=lightgray><th bgcolor=cyan> A Clock", end='')

for col_head in range(60) :                                         #column headers 0-59
    print("<th>", col_head, end='')                       
print("</tr>")

for hour in range(24) :                                             #the outer loop 0-23
    print("<tr>", end='')
    print("<th bgcolor=lightgray> HOUR", hour, "</th>", end='')     #row headers

    for minute in range(60) :                                       #the inner loop 0-59
        print("<td>", minute, "</td>", end='')

    print("</tr>")

print("</table>")
print("</body>")
print("</html>")





#=== link to see the python code =================================================
import os, sys
sys.path.insert(0,'/home/s/sultans/web/python/demo')
import zCode                          #import func to display the Python code
filename = os.path.abspath(__file__)  #get absolute file name 
zCode.display(filename)               #call it
#=================================================================================