写一个计算工资和平均工资的程序
employeeSum = 0
employeesalary = []
for i in range(4):
s = input("输入4名员工工资按q结束")
if s.upper() == "q" and "Q":
break
if float(s) < 0:
continue
employeesalary.append(float(s))
employeeSum += float(s)
else:
print("已输入完毕")
print("四名员工工资分别为{}".format(employeesalary))
print("四名员工的平均工资为{}".format(employeeSum/len(employeesalary)))
ValueError: could not convert string to float: 'q'
我始终不能理解为什么会这样,正常情况应当是在输入q时触发break直接逃出到print里