I have a problem with a program I am making to do with an arithmetic quiz.when I enter a name the quiz should print the welcome message however if I enter a blank or a number then the programme should loop the question but tell the user that they have made an error. I used the try statement and the NameError statement to try and resolve this problem but when I use the function "except" and run it in idle it says that I have an invalid syntax.
here is the code i am trying to fix:
import random
while True:
try:
UserName = input("What is your name:")
except NameError:
print ("The answer given does not compute!! Try again")
continue
else:
break
print(UserName," welcome to the Arithmetic Quiz.")
I have edited the code for the program, but still when I try to run it in Idle it highlights except and then says invalid syntax.