I'm just attempting to put in an exception where the user inputs a non numeric value, so that the program gives an error message and quits. However, using quit()
like I have, it still attempts to run the end of the code (variable not defined
error), and gives me an error that the kernel has died. What is the correct way to quit out of the code with the exception?
try:
inp=raw_input("Enter Hours Worked ")
hours=float(inp)
inp=raw_input("Enter Pay Rate ")
rate=float(inp)
except:
print "Error: Enter a numeric value"
quit()
if hours<=40:
pay = hours * rate
else:
pay = (hours-40) * rate * 1.5 + (40 * rate)
print "Gross Pay: $",pay