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
- Make
assign(goal, crew)that getspip.plan(goal)and returns a list of jobs likeAda: send the invites. - Hand out the steps in turn with
i % len(crew), so it works for any size of crew. - 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.
bot.py
Terminal