Aug-22-2018, 02:29 PM
I compiled the following first steps of a quiz:
NameError: global name 'user_answer_easy_test_1' is not defined
Can you help me to solve this problem? Thanks a lot in advance!
easy_text = '''The Simpsons is an animated sitcom created by ___1___ . The father of the family is called ___2___ and the mother's name is ___3___ . Both have a naughty son who is called ___4___ .''' list_of_easy_text = easy_text.split() #list with correct answers in easy_text: list_answers_easy_text = ['Matt Groening', 'Homer', 'Marge', 'Bart'] #User is asked to fill in blanks in easy_text: def play_easy_text(): user_answer_easy_test_1 = raw_input("Your answer for ___1___:") print user_answer_easy_test_1 check_correct_easy_text() play_easy_text() def check_correct_easy_text(): if user_answer_easy_test_1 == list_answers_easy_text[0]: print "Your answer is correct!" else: print "Your answer is wrong. Try it again!" check_correct_easy_text() def determination_level(): level = raw_input("Choose: easy, medium, hard.") if level == "easy": print "You have chosen the level 'easy'." print easy_text play_easy_text() elif level == "medium": print "You have chosen the level 'medium'." elif level == "hard": print "You have chosen the level 'hard'." else: print "Wrong input!" determination_level() determination_level()When I run this code, I get the following error:
NameError: global name 'user_answer_easy_test_1' is not defined
Can you help me to solve this problem? Thanks a lot in advance!