So I have written this code for this game, using a user input, but it does not seem to be working. This is my code.
import random
print ("Welcome to the hungry dog game.")
print ("The aim of this game is to save the hungry dog. How long can you keep it alive for?")
true = True
false = False
aliveordeadlist1 = [true, false]
random.choice(aliveordeadlist1)
feed1 = input("Ok so here's your first choice. Are you going to feed your dog now or not?(he doesn't look very hungry...) type in yes or no.")
if feed1 == "no" and aliveordeadlist1 == false:
print ("Well you were wrong, he was hungry. Your dog died sorry. Better luck next time.")
if feed1 == "yes" and aliveordeadlist1 == false:
print ("As I told you he wansn't hungry> You overfed him so hed died sorry. Better luck next time.");
if feed1 == "no" and aliveordeadlist1 == true:
print ("Well done he wasn't hungry. He is still alive (for now...)");
if feed1 == "yes" and aliveordeadlist1 == true:
print ("Well done he actually was hungry so he would have died if you didn't feed him.He is still alive (for now...)");
When I run this code in the shell and for example, type yes, it returns this error:
Traceback (most recent call last):
File "/Users/mac/Documents/hungrydoggame.py", line 16, in <module>
feed1 = input("Ok so here's your first choice. Are you going to feed your dog now or not?(he doesn't look very hungry...) type in yes or no.")
File "<string>", line 1, in <module>
NameError: name 'yes' is not defined
I am unsure why I am receiving this error and what I should do to fix it, does anyone have any suggestions?
raw_input()