2

Using this code:

import random import query import sys while True: try: number = int(input('Choose a number between 0 and 10:')) except ValueError: print("That is not a number.") continue if number > 10: print('Your number is too large.') continue elif number < 0: print('Your number is too small.') continue break result = random.randint(0, 10) print("You're number: " + str(number)) print("Our number: " + str(result)) if number == result: print('Congratulations!') else: print('Close, but no cigar.') while True: try: answer = query.query_yes_no('Do you wish to contunue?') if answer == "yes": while True: try: number = int(input('Choose a number between 0 and 10:')) except ValueError: print("That is not a number.") continue if number > 10: print('Your number is too large.') continue elif number < 0: print('Your number is too small.') continue break print("You're number: " + str(number)) print("Our number: " + str(result)) if number == result: print('Congratulations!') continue else: print('Close, but no cigar.') continue elif answer == "no": print('Goodbye.') break break break exit() 

I keep getting a SyntaxError: unexpected EOF while parsing. It says it is on line 60. I have tried removing the exit() and the breaks but that doesn't work. I'm sure it is something simple as I am still new to Python. Any help would be greatly appreciated!

1 Answer 1

3

You need to include another except for the first try inside your infinite while loop. That's why, it may be giving a syntax error.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! That fixed it! I took out the last 2 breaks and the exit() and added except:pass and it is working as intended now.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.