Lesson 5 of 6
Choices that change the story
In an RPG, every choice has consequences: an if on the choice variable decides what happens next.
Here the player picked their path; your program applies the game rule based on the value of choice.
if choice == "left":
gold = gold + 10
else:
gold = gold - 5🎯 Your mission
The hero has gold = 10 coins and took the path choice = "left". Game rule: the "left" path leads to treasure (+10 coins), any other path leads to a trap (-5 coins). Apply the rule with if/else, then print gold.
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →