我写了一个Python,让用户猜一个数字。如果我想在用户每次正确猜出数字时都显示最高分,我应该在代码中添加什么?
import random
correct_answer = random.randint(1, 100)
count = 0
while True :
number = int(input("Enter a number: "))
count += 1
if correct_answer == number :
print("Correct.", count, "tries")
one=input("Do you want to play it again?")
if one=='no':
print("Okay")
break
elif one=='yes':
print("okay")
elif correct_answer > number :
print("greater than", number)
else :
print("less than", number)