Identifying prices
After you showed your report to your boss, he came up with the idea of offering courses to the company's users on some of the tools you studied. In order to make a pilot test, you will send an email offering a course about one of the tools, randomly chosen from your dataset. You also mention that the estimated fee needs to be paid on a monthly basis.
For writing the email, you will use Template strings. You remember that you need to be careful when you use the dollar sign since it is used for identifiers in this case.
For this example, the list tools
contains the corresponding tool name, fee and payment type for the product offer. If you want to explore the variable, you can use print()
to view it in the IPython Shell.
This exercise is part of the course
Regular Expressions in Python
Exercise instructions
- Assign the first, second, and third element of
tools
to the variablesour_tool
,our_fee
andour_pay
respectively. - Complete the template string using
$tool
,$fee
, and$pay
as identifiers. Add the dollar sign before the$fee
identifier and add the charactersly
directly after the$pay
identifier. - Substitute identifiers with the three variables you created and print out the results.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import template
from string import Template
# Select variables
our_tool = ____
our_fee = ____
our_pay = ____
# Create template
course = ____("We are offering a 3-month beginner course on ____ just for ____ ____ ____")
# Substitute identifiers with three variables
print(____.____(____=____, ____=____, ____=____))