基本上,每当我进入程序的数学部分时,它就会告诉我列表索引必须是整数或切片,而不是浮点型。我正在遍历创建的两个不同列表,并且根据我的IDE,两个列表都根据用户输入获取正确的值。但是,到了将元素相乘的时候了。我收到上述错误。
代码如下:
START = input("Type START if you want to start inputting employee names: ")
employee_list = []
employee_hours = []
employee_wage = []
pay_range = [300, 550, 800, 800.01]
tax_witholding = [.10, .13, .16, .20]
payAfterTax = 0
payAfterTax = (float)
while START == "START":
employee_list = input("Type in Employee Name: ")
employee_hours = int(input("Type in the amount of hours they have worked: "))
employee_wage = float(input("Type in how much they make per hour: "))
START = input("If you are done inputting employees then type DONE: ")
if START != "START":
break
print("Employee name: ", employee_list, "Hours Worked: ", employee_hours, "Employee Wage: ", employee_wage)
grossPay = employee_hours * employee_wage
grossPay = float(grossPay)
print("Gross pay: ", grossPay)
for i, x in zip (pay_range, tax_witholding):
if grossPay <= i :
payAfterTax = grossPay - (grossPay * tax_witholding[x])
print("Pay after taxes: ",payAfterTax)