0
我一直在外部代碼來源寫我的計算機科學作業,時間多久需要有人猜測一個問題。外部代碼來源作業
然而,當我運行它,我收到此錯誤:
Traceback (most recent call last):
File "E:/Documents/Guess band member.py", line 14, in <module>
start = time.time()
AttributeError: 'float' object has no attribute 'time'
我將不勝感激,如果有人可以幫助我解決這個問題。
import time
print("You can type 'quit' to exit")
Exit = False
Band = ["harry", "niall", "liam", "louis" ]
while Exit == False:
print("Guess a band member")
start = time.time()
Guess = input(":")
end = time.time()
Guess = Guess.lower()
if Guess == 'quit':
Exit = True
elif Guess in Band:
print("You're right")
elif Guess == "zayn":
print("Wrong")
print("He left.")
else:
print("Fool!")
time = end - start
print("You took", time, "seconds to guess.")
'time = end - start'? – jonrsharpe