Every time I run my code it says this:
Traceback (most recent call last):
File "/Users/syedrishad/PycharmProjects/OpenCVPython/venv/Reaction Test.py", line 14, in <module>
tic = time.clock()
AttributeError: module 'time' has no attribute 'clock'
I understand that it got removed but now I don't know how to alter my program. Can someone please fix it. It's supposed to be a reaction test.
import time, random
rounds = int(input('How many rounds do you want to play?'))
times = []
for i in range(0,rounds):
print('when I say __GO__ you hit ENTER!. got it?')
time.sleep(1)
print('ready')
time.sleep(1)
print('steady')
time.sleep(random.randint(2,5))
print('#####__GO__######')
tic = time.clock()
a = input()
toc = time.clock()
timeSpent = toc-tic
times.append(timeSpent)
print('your time was '+str(timeSpent) + ' seconds')
print('fastest time was ' + str(min(times)))
print('slowest time was ' + str(max(times)))
average = sum(times)/len(times)
print('the average time was ' + str(average))
Any help would be appreciated. I've been stumped over this for a while now.
Aucun commentaire:
Enregistrer un commentaire