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!

Stephen Rauch
50.1k32 gold badges119 silver badges143 bronze badges
asked Feb 8, 2017 at 0:51

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.

answered Feb 8, 2017 at 0:56
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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.