Build Your First AI Agent / Chapter 1: Hello, Bot
Feedback
Quest

05. Snack Counter

A for loop repeats lines for you. range(1, 4) counts 1, 2, 3: it stops just before the second number.

for n in range(1, 4):
    print("Step", n)
print("Done!")
Step 1
Step 2
Step 3
Done!

Lines indented under the loop repeat. The line back at the left edge runs once, after the loop. Finish this one and your bot earns its first badge.

Instructions

  1. Use a for loop with range(1, 6).
  2. Inside the loop, print Snack and the number: Snack 1 up to Snack 5.
  3. After the loop, print Crunch complete! once, as the last line.
Hint

for n in range(1, 6): then, indented, print("Snack", n). Then, back at the left edge, print("Crunch complete!").

Solution
for n in range(1, 6):
    print("Snack", n)
print("Crunch complete!")
Still stuck?

Press "Talk it out" at the top. Our Discord opens soon; until then email us and paste your code.

Chapter quests
  1. Chapter 1: Hello, Bot
    1. Wake Up 10 XP
    2. Name Tag 10 XP
    3. Mood Ring 10 XP
    4. Echo Echo 10 XP
    5. Snack Counter 15 XP
  2. Chapter 2: Talk to the Model
  3. Chapter 3: Tools CLUB
  4. Chapter 4: Memory CLUB
  5. Chapter 5: Loops and Plans CLUB
  6. Chapter 6: Party of Agents CLUB
bot.py
Terminal
Chapter 1: Hello, BotQuest 5 / 515 XPBackNext

Talk it out

  1. What did you expect your bot to do?
  2. What did it actually print? Read the terminal, line by line.
  3. What's different? Spelling, capitals, spaces and full stops all count.
  4. Is there an error? It tells you the line number. Look there first.
  5. Read the instructions again, one at a time. Each one is checked on its own.

Badge unlocked:

Your bot got a new part. Chapter complete!

Make your bot

Pick a name and a colour. You can change them later.