I am writing a program that will ask the user to enter in an integer, and if it is not an integer, i will print "Error" and exit the program.
I tried this:
userNumber = input()
try:
val = int(userNumber)
except ValueError:
print("Error")
exit()
But this is not working and is giving me an error.
How can I fix this?
NameError's in your code.valueErrorshould beValueErrorandprintfshould beprint. Also, your indentation is messed up.