The Bear Game šŸ»| 1st Time With if/elif/else Statements

Jesse Sumrak
Becoming a Developer
2 min readNov 28, 2018

This morning learning about if/elif/else statements in my Udemy Python course. Super interesting and incredibly simple. I imagine it gets a whole lot more intense (and complicated), but it was fun to just play around with what I was learning. So I decided to create a short little game. Okay, hardly a game, but just wanted to play around a little bit with the inputs and statements. Then I realized that this is basically what the entire Oregon Trail game is made up ofā€¦that and some mediocre front-end, but thatā€™s it. Canā€™t wait to learn more and dive deeper into this. Hereā€™s my water downed code I used in the experiment for my bear game. šŸ»

print("Hey! Ready to play? First, tell me a little about yourself.")
name = input("First, what's your name? ")
print("Great to meet you, {0}!".format(name))
age = int(input("Next, how old are you? "))

if age >= 27:
print("Holy tish! {0}, you're old as crap.".format(name))
elif age <= 25:
print("You're a young lad, {0}.".format(name))
else:
print("Hey, {0}! Me too!".format(name))

print("Okay, let's set the stage. You're walking through a dense forest\n"
"when suddenly you happen upon a bear.")
bearChoice = input("What do you do? Run or fight? ")

if bearChoice == "run":
print("Smart choice. That bear would have ripped you apart. You win the game!")
elif bearChoice == "fight":
print("Well, that was stupid...You're dead!")
else:
print("I don't think that was an option. I'll let you try again.")
bearChoice = input("What do you do? Run or fight? ")
if bearChoice == "run":
print("Smart choice. That bear would have ripped you apart. You win the game!")
elif bearChoice == "fight":
print("Well, that was stupid...You're dead!")

--

--

Jesse Sumrak
Becoming a Developer

Jesse Sumrak is a writing zealot focused on creating killer content. Heā€™s spent almost a decade writing about startup, marketing, and entrepreneurship topics.