Oct-04-2018, 07:05 PM
hi guys. I would like to know how to reject invalid user inputs, or write exceptions in this loop. Ive never done it in a for loop, but I have to use one.
lowTaxStates=['California','Nevada', 'Arizona', 'Washington'] for i in range(6): employeeName= input('Enter name of employee: ') employeeSalary=float(input('Enter yearly salary of employee: ')) employeeState= input('Enter full name of the state of residence for employee: ') if employeeSalary>100000.00: federalTaxes=0.20*employeeSalary else: federalTaxes=0.15*employeeSalary if employeeState in lowTaxStates: stateTaxes= 0.10*employeeSalary else: stateTaxes=0.12*employeeSalary netSalary=employeeSalary-federalTaxes-stateTaxes print('Net salary for employee is :', netSalary ) print(""" """)