When the user gives wrong input for tax_rate
, it should ask user the correct input for that variable, but instead it is starting from first, asking the hr_rate
input which is already received.
while True:
try:
hr_rate = float(input("Enter Hourly Rate: "))
emp_ot_rate = float(input("Enter Overtime Rate: "))
tax_rate = float(input("Enter Standard Tax Rate: "))
ot_tax_rate = float(input("Enter Overtime Tax Rate: "))
except Exception:
print("Invalid entry, please retry")
Output:
Enter Hourly Rate: abc
Invalid entry, please retry
Enter Hourly Rate: 10.2
Enter Overtime Rate: 20.25
Enter Standard Tax Rate: abc
Invalid entry, please retry
Enter Hourly Rate:
The last line should ask for Standard Tax Rate again.