Write a python program that prompts the user to enter a few details: fullname, age, job, country and salary which are going to be included in an html file.
# A simple example of reading write data to a file
# and opening it in a browser
import webbrowser
name = input("Enter fullname: ")
age = input("Enter age: ")
job = input("Enter job: ")
country = input("Enter country: ")
salary = input("Enter salary: ")
html= f"""
<!DOCTYPE html>
<html lang="en">
<head>
<title>A simple HTML document</title>
</head>
<body>
<p>Full name {name}<p>
<p>Age {age}<p>
<p>Job {job}<p>
<p>Country {country}<p>
<p>Salary {salary}<p>
</body>
</html>
"""
file_name = "example.html"
with open(file_name, "w") as file:
file.write(html)
# open in browser
webbrowser.open(file_name)
Comments
Leave a comment