0%
⭐ 0 XPMap
Chapter 6 · Quest 2 of 4 · 10 XP

Boss and Crew

👑 Bigger jobs need a boss. The boss makes the plan, then hands each step to a crew member, taking turns. With 2 crew and 3 steps, the first crew member gets steps 1 and 3.

crew = ["Ada", "Bo"]
for i in range(3):
    print(crew[i % len(crew)])
Ada
Bo
Ada

Using len(crew) instead of 2 means it still works when you hire a third crew member. enumerate() without a start number counts from 0, which is just what list positions need.

Instructions

  1. Make assign(goal, crew) that gets pip.plan(goal) and returns a list of jobs like Ada: send the invites.
  2. Hand out the steps in turn with i % len(crew), so it works for any size of crew.
  3. Print each job from assign("throw a party", ["Ada", "Bo"]).
💡 Hint

Inside assign: jobs = [], then for i, step in enumerate(pip.plan(goal)): jobs.append(crew[i % len(crew)] + ": " + step). Return jobs.

Ask the community

bot.py
Terminal
← BackNext →

Chapter 6: Party of Agents

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.