Step 3 of 3
Two upgrades: wrap the whole thing in a loop so it keeps going, then add protection so one name can never be roasted.
π while loop π break
Wrap your roast code in a while True loop so it keeps asking until the user types quit:
while True: name = input("Enter a name (or 'quit' to stop): ") if name == "quit": break level = input("Pick a roast level β mild or savage: ").lower() # ... rest of your roast code here
Things to figure out:
while True mean β why doesn't it stop on its own?break do?π if/else π String comparison
Before generating the roast, check if the name matches a protected name. If it does, print a special message instead:
your_name = "Ms Johnson" # change this to whatever name you want to protect if name == your_name: print("Nice try. I don't roast legends.") else: roast = random.choice(starters) + " " + name + ", " + random.choice(middles) + " " + random.choice(endings) print(roast)
Put Part A and Part B together in the editor below. The full program should:
quit