#filename: 2example1.py # This is all the introduction. Nothing exciting, just text to describe the situation. print("WELCOME TO THE LUXURIOUS BEACH!") print("You are standing on a rock with two caves in front of you and a hill behind you") print("What will you do?") print(" 1 ... Left cave") print(" 2 ... Right cave") print(" 3 ... Up the hill behind you") # The player will be given a line starting with ">" to type in their response. # Now, because people make typos or intentionally try to break games, the code keeps looping # until the player types in "1" or "2" (try running the program to check this) response = "" while response not in ["1", "2", "3", "4"]: response = input("> ") # We now know for sure that they either typed "1" or "2". # So, depending on which they typed in, we need to say if they won or not! if response == "1": print("You walk through the left cave.") print("Inside you find a room full of treasure. Congratulations, you have won!") elif response == "2": print("You walk through the right cave.") print("Inside you find a room containing a giant tiger! The tiger licks his lips and then pounces.") print("You are dead. Game over...") elif response == "3": print ("You walk up the hill.") print ("There is nothing there. That was boring.") print ("You try to walk back down but you slip.") elif response == "4": print ("Is this a secret?") print("Yes or No. Please use a capital letter at the start, or would not work.any") response2 = "" while response2 not in ["Yes", "No", "yes", "no"]: response2 = input(">> ") if response2 == "Yes": print("Wow this is a secret. You just typed in the number 4 and got here or you inspected the code to find this hidden \nstring") print("Wow.") elif response2 == "No": print("Oh ok")