def pay():
hours = input("Enter hours: ")
rate = input("Enter rate: ")
try:
hours = int(hours)
rate = int(rate)
except:
print("Not a valid number!")
return pay()
if hours > 40: rate *= 1.5
return "Pay: $" + str(hours * rate)
print(pay())
The above function works, but I was wondering how can we use recursion if the input in not an int.
Should I even use inputs here? I'm new to python and programming in general.
I recon we shouldn't use inputs when not required. Right?