Generate a Personalized Email Greeting
Beginner · Write the code · from Python String Formatting: f-strings, format(), and % Operator
From the lesson: Python String Formatting: f-strings, format(), and % Operator
Imagine you're building a receipt for a coffee shop. You need to combine a product name, a price, and a quantity into one clean line. You could glue strings together with +, but it gets messy fast.
Read the lessonCreate these variables:
first_name = "Jordan"items = 3total = 89.95Then use a multiline f-string (triple quotes) to print this exact message:
Hi Jordan,
Thank you for your purchase of 3 items.
Your total is $89.95.
Have a great day!Make sure the total shows exactly 2 decimal places.
# Create the variables and print the email greeting
More String Formatting exercises
- Format a Receipt LineBeginner
- Format a Large Number with CommasBeginner
- Create a Formatted Table RowBeginner
- Fix the Broken f-stringBeginner
All Python exercises · 50 practice problems · Python Fundamentals quiz