I'm new in programming and I have an issue when doing the input validation.
My program requires to input number from 1 to 10 or the letter y but it seems that I cannot do an error handler for this.
def checkingInput():
while True:
try:
a = input()
if 10 >= a >= 1 or a == 'y':
return value
else:
print('Invalid input!')
except NameError:
print('Name error!Please try again!')
except SyntaxError:
print('Syntax Error!Please try again!')
print()but could you please confirm that?SyntaxErroris not an exception that normally happens at runtime.ValueErrorinstead ofSyntaxError. Also you can't compareintswithstringsso you should change your line toif a == 'y' or 1 <= int(a) <= 10