I'm currently going through Learn Python The Hard Way Exercises and wanted to try writing my own code to let a user choose different paths. When I run the code below, I don't get a name error for "first_decision". However, I keep getting a name error saying it's not defined for the variable "second_decision". I am running Python 2.7.10. Does anyone know why this is?
Error Here:
NameError: name 'second_decision' is not defined
Code Here:
print "This is the root level where we now create 3 branches of decisions. 1, 2, or anything else"
first_decision = raw_input("> ")
print "You chose %r" % first_decision
if first_decision == "1":
print "This is the context after player makes the first choice"
print "Once here, we can let the player make another decision. 1, 2, or 3"
second_decison = raw_input("> ")
print "You chose %r" % second_decision
if second_decision == "1":
print "This is two levels deep"
elif second_decision == "2":
print "This is two levels deep"
else:
print "Everything else for the second level"
elif first_decision == "2":
print "This is the second context after player makes the first choice"
print "Once here, we can let the player make another decision. 1, 2, or 3"
second_decison = raw_input("> ")
print "You chose %r" % second_decision
if second_decision == "1":
print "This is two levels deep"
elif second_decision == "2":
print "This is two levels deep"
else:
print "Everything else for the second level"
else:
print "This is for everything else"
Aucun commentaire:
Enregistrer un commentaire