Making Functions
Today, start off by looking at your outline and define functions with the names of each of your rooms. In addition, make a game over, start, and a win function. You can go back to day 2 if you do not remember how to create functions. Once you are done, check in with Shriya.
Once you have done that, write the choices that show up in each of your rooms using print statements. Create a welcome message in your start function, a win message in your win function, and a game over message in your game over function.
Next, I would like you to make input statements for all of your rooms that ask the user what choice they would like to make. Then, utilize if, elif, and else statements to send the user where they need to go accordingly.
If you are struggling, you can look at the "Example" tab.
def start():
# give some prompts.
print("You are standing in a dark room.")
print("There is a door to your left and right, which one do you take? (l or r)")
# convert the player's input() to lower_case
answer = input(">").lower()
if "l" in answer:
# if player typed "left" or "l" lead him to bear_room()
bear_room()
elif "r" in answer:
# else if player typed "right" or "r" lead him to monster_room()
monster_room()
else:
# else call game_over() function with the "reason" argument
game_over("Don't you know how to type something properly?")
# start the game
start()
# taken from thecodingpie.comLast updated
Was this helpful?