-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoy.py
More file actions
29 lines (23 loc) · 656 Bytes
/
toy.py
File metadata and controls
29 lines (23 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# To view the generated HTML page, run:
# python3 toy.py > MISC.html
#
# The main page of the html
PAGE_HTML = """
<p>Welcome, {name}!</p>
<p>Products:</p>
<ul>
{products}
</ul>"""
PRODUCT_HTML = """ <li>{product_name}: ${product_price}</li>
"""
def make_page(username, products):
product_html = ""
for name, price in products.items():
product_html += PRODUCT_HTML.format(
product_name=name,
product_price=price
)
return PAGE_HTML.format(name=username, products=product_html)
print(make_page("Hafs", {"Apple": 1.00,
"Fig": 1.50,
"Pomegranate": 3.25}))