total = 0
fastest=9999
slowest=0
laps = input("How many laps?")
for i in range(laps):
lap_time = input("Please enter laptime?")
if lap_time > fastest:
fastest = lap_time
elif lap_time < slowest:
slowest = lap_time
total = total + lap_time
print("fastest =>",fastest)
print("slowest =>",slowest)
print("total =>",total)
print("average =>",total/laps)
我收到了类型错误 我在范围内(圈): TypeError:'str'对象不能解释为整数
有人可以帮助我,我是新的
由于
答案 0 :(得分:0)
当你从input
得到一个值时,它被解释为一个字符串,一个字符值。
要将值用作整数,请执行
laps = int(input("How many laps?"))