# Simple program to write a basic HTML file and display it in the default browser. # adapted from http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/webtemplates.html import webbrowser, os.path def strToFile(text, filename): """Write a file with the given name and the given text.""" output = open(filename,"w") output.write(text) output.close() #the following string stores the contents of a very basic HTML page contents = ''' Hello

Hello, World!

''' for i in range(10): contents += f"This is span {i}." contents += ''' ''' #the filename for the HTML file to be created filename = "helloWorld.html" #write the HTML contents to a file strToFile(contents, filename) #open the HTML file in the default browser webbrowser.open("file:///" + os.path.abspath(filename))