Created
September 16, 2020 14:50
-
-
Save israel-dryer/036f0118ebe0a9e4548873c10794dade to your computer and use it in GitHub Desktop.
Insert python list into html formatted email template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create a html formatted list from a python list | |
""" | |
# email template with curly braces to insert list | |
email_template = ''' | |
<p>Hello, here are the items that you ordered:<br> | |
{} | |
</p> | |
''' | |
# the list of products the customer ordered | |
products = ['Radio', 'Computer', 'Monitor'] | |
# build an html formatted list from the python list | |
html_list = "<ul>" | |
for prod in products: | |
html_list += f"<li>{prod}</li>" | |
html_list += "</ul>" | |
html_body = email_template.format(html_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment