Hi! I'm making a little text adventure in the console, and i figured that instead of writing in the restart code at the end of every statement, i'd just make a function and paste it at the end.
The lesson i'm making it in: https://www.codecademy.com/en/courses/python-beginner-BxUFN/4/1?curriculum_id=4f89dab3d788890003000096
However, i can't get the conditions of the if statements in try_again() to evaluate the strings from tryagain without typing in the quotes in front and behind it into the console input, and when i do type in 'n' and the program stops like intended with print "Thanks for playing!" running at the end, i get his error message:
Oops, try again. The following exception was raised when calling the_flying_circus(): SyntaxError: unexpected EOF while parsing (, line 0)
I don't get any errors in the console. Anyway, here's the code. I hope i was specific enough.
def try_again(): tryagain = input("Wanna try again? \nY or N :").upper() if tryagain == 'Y': the_flying_circus() elif tryagain == 'N': print "Thanks for playing!" return True else: print "Y or N, buddy" try_again()
def the_flying_circus(): num = int(input("Welcome to the number freak 1.0! Type in a number between 0 and 10!")) if num <= 5: go_higher = int(input("Why, you're laying flat on the floor! Go higher!")) if go_higher < num: print "Well, let's just burry our heads in the sand then..." try_again() elif go_higher > num and go_higher < 10: print "Well, that is admittedly higher, but i was thinking more adventurous.." try_again() elif go_higher > 10: print "Now we're talking!" try_again() else: print "Buddy, just stick to the numbers" try_again() elif num >= 6 and num < 10: print "That's definitely on the high side! Could do better, though." try_again() elif num > 10: print "A rebel off the batt, eh? I like it!" else: print "A number would do just fine" try_again() the_flying_circus()