0%
⭐ 0 XPMap
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

  1. Make two text variables: name and thing.
  2. Build prompt with an f-string: f"Tell a fortune for {name} who loves {thing}."
  3. 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.

Ask the community

bot.py
Terminal
← BackNext →

Chapter 2: Talk to the Model

The full quest map

Talk it out

  1. Read the instruction with the ✗ out loud.
  2. Say what your code does, line by line, as if to a friend.
  3. Find the line where what it does and what you want split apart.
  4. Press Run and read the terminal. Is that what you expected?
  5. Still stuck? Press Ask Pip why, or peek at the solution.
  6. Or ask on the community help board: say which quest, and paste your code.
New badge!

Your bot just got a new part. See it on the quest map.

Name your bot

It levels up as you play, and gets a new part with every chapter.