0%
⭐ 0 XPPractice
Pack 2 · Challenge 4 of 5 · 10 XP · ⏱ 4 min

Joke Machine

😂 Loops and prompts together: ask Pip for three jokes and number them. (Pip only knows one joke. It's a tiny model.)

for n in range(1, 3):
    print("Round " + str(n))
Round 1
Round 2

Instructions

  1. Loop n from 1 to 3 with range.
  2. Each time, print Joke 1: and then pip.ask("Tell me a joke"), with the right number.
💡 Hint

for n in range(1, 4): print("Joke " + str(n) + ": " + pip.ask("Tell me a joke")).

Ask the community

bot.py
Terminal
← BackNext →

Prompt Gym

All practice packs

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.