how do I put python in html code example

Example 1: how to connect python to html

data = [1, 2, 3, 4]


def data_to_html_table(data):
    html = '<table><tbody>'
    for item in data:
        html += '<tr><td>' + str(item) + '</td></tr>'
    html += '</tbody></table>'
    return html

print data_to_html_table(data)

#credit to stackoverflow.com

Example 2: python in html

<!-- 
Unfortunetly, it's the other way around
You should use the flask module on python to build sites
Check the source for a great tutorial on flask



Or you can use Brython, a javascript replacement which is like python
-->