0

I'm writing a simple exception handler in Python 3.5 to check if user input is an integer. I'm wondering what the standard practice is for exiting a program if the input is invalid.

#Excersise working with number exceptions

user_in = input("Please enter a number: ")

try:
    val = int(user_in)
except ValueError:
    print("Invalid int")
    #exit statement here

print ("You entered: " + str(user_in))
  • 1
    `sys.exit(1)` I guess – Joran Beasley Dec 24 '15 at 07:41
  • both exit() and quit() are instances of the same Quitter class, the difference is in naming only, that must be added to increase user-friendliness of the interpreter. Furthermore, you can use each of them. – Arman Dec 24 '15 at 07:45

0 Answers0