I'm trying to figure out how to get try/except to work within a function.
Here is what I have now and it produces a traceback error when I enter anything not numeric (e.g. "forty").
def computepay(hours=float(input('Enter hours worked: ')), rate=float(input('Enter hourly rate: '))):
try:
if hours <= 40:
print('pay:', hours * rate)
else:
ot_rate = rate * 1.5
ot_hours = hours - 40
print('pay: $', (ot_hours * ot_rate) + (40 * rate))
except NameError:
print('Error, please enter numeric input')
computepay()