【发布时间】:2013-08-12 18:13:49
【问题描述】:
我有这个程序可以计算回答特定问题所需的时间,并在答案不正确时退出 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))
【问题讨论】:
-
你试过
lst.pop()吗?
标签: python time python-3.x