Here is the code I have written. Everything runs as expected. My question is, when I type a non-integer and receive the Error message the Pay is still printed with the repeating non-integer entered. How can I fix what I have to either not print Pay or leave it blank?
hours = input("Enter Hours: ")
rate = input("Enter Rate: ")
ot_rate = 1.5
try:
hours = int(hours)
rate = int(rate)
except:print("ERROR, please enter numeric input")
def computepay(hours, rate):
if hours > 40:
ot_hr = hours - 40
hours -= ot_hr
ot_pay = ((ot_hr) * (rate) * (ot_rate))
return (hours * rate) + ot_pay
else:
return (hours * rate)
print("Pay:")
print(computepay(hours, rate))