我有这个程序,计算回答特定问题所花费的时间,并在答案不正确时退出while循环,但我想删除最后的计算,所以我可以调用min(),这不是错误的时间,抱歉,如果这是令人困惑的。
from time import time
q = input('What do you want to type? ')
a = ' '
record = []
while a != '':
start = time()
a = input('Type: ')
end = time()
v = end-start
record.append(v)
if a == q:
print('Time taken to type name: {:.2f}'.format(v))
else:
break
for i in record:
print('{:.2f} seconds.'.format(i))