Hi, I am new (actually very new) to using Python and I am trying to figure out how to stop code from running and printing error message if there is an error using try/except. I thought I could add quit() or sys.exit(1) , but both of those are not recognized and come back with an error code of their own. Any help would be greatly appreciated. Here is the code:
def computepay(h,r):
return(h*r)
hrs = input("Enter Hours:")
rate = input('Enter Rate:')
try:
h = float(hrs)
r = float(rate)
except:
print('Error, please enter numeric value')
quit()
p = computepay(h,r)
print("Pay",p)