print "HEllo !!"
print "Today, I will calculate something for you !!"#introduces itself
inp = True
def start():
print "type 1 for ADDITION"
print "type 2 for SUBTRACTION"
print "type 3 for MULTIPLICATION" #asks for the kind of calculation
print "type 4 for DIVISION"
press=int(raw_input())
if press >= 5 :
print "Choose a NUMBER which is less than 5 and you will get the answer!!"
print "-------------------------------"
if press == 1:
print "Enter your first number"
num1 = input()
print "enter your second number" #adds
num2 = input()
result = num1 + num2
print " Your answer is "+ str(result)
print "-------------------------------"
if press == 2 :
print "Enter your first number"
num1 = input()
print "enter your second number" #subtracts
num2 = input()
result = num1 - num2
print " Your answer is "+ str(result)
print "-------------------------------"
if press == 3:
print "Enter your first number"
num1 = input()
print "enter your second number"
num2 = input() #multiplies
result = num1 * num2
print " Your answer is "+ str(result)
print "-------------------------------"
if press == 4:
print "Enter your first number"
num1 = input() #divides
print "enter your second number"
num2 = input()
result = num1/num2
print " Your answer is "+ str(result)
print "-------------------------------"
while inp :
start()
So I've created this calculator using basic commands, and the only problem is when someone types in a letter, where it asks for a number from 1 to 4, it shows a python error. Instead I want to be able to print a custom made error like "only number allowed" or something like that instead of the regular error that python shows. What change can I do so that it takes in numbers and alphabets, but shows a custom-made error when someone enters a letter ? P.S. : I am asking for the var "press" and not about "num1" or "num2"