每次用户玩游戏时显示最高分数

时间:2018-11-19 18:23:27

标签: python

我写了一个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)

0 个答案:

没有答案