Chapter 2 · Quest 3 of 5 · 10 XP
Fortune Teller
🔮 Most prompts are built from pieces. An f-string (an f right before the quotes) lets you drop variables into text with curly brackets.
food = "tacos"
msg = f"I could eat {food} every day."
print(msg)I could eat tacos every day.
That's a prompt template: the same sentence, filled in with different words each time.
Instructions
- Make two text variables:
nameandthing. - Build
promptwith an f-string:f"Tell a fortune for {name} who loves {thing}." - Print
pip.ask(prompt).
💡 Hint
Put an f right before the opening quote, and the variable names inside { }. Keep the full stop at the end.
bot.py
Terminal