Steadily trying to learning Python basics…I’m trying to create a score variable here…but I get an “unresolved reference” error in the ‘choice_of_path’ function.
Can someone explain why? I refer to ‘Score’ in the top of the code?
Thanks! I assume this is something simple I don’t quite get! - Matt
name = input("What is your name? ")
score = 0
print("Great to see you, " + name)
def choice_of_path(question, right_answer, left_answer,):
choice1 = input(question) if choice1 in ['R', 'r', 'right', 'Right', 'RIGHT']: print (right_answer) score += 1 elif choice1 in ['L', 'l', 'left', 'Left', 'LEFT']: print (left_answer) else: print("You didn't choose the right thing! Try again")
choice_of_path(“You are in a field with lots of grain, which way do you go?”, “You got swallowed”, “You won the gold!”)
choice_of_path(“You are now in a basketball stadium, which way do you go?”, “You scored a big goal”, “You lost game!”)