from random import *
while True:
random1 = randint(1,20)
random2 = randint(1,20)
print("h = higher, l = lower, s = same, q = quit")
print(random1)
a = input()
if a.lower() == 'q':
break
print(random2)
if a.lower() == 'h' and random1 < random2:
print("Well done")
elif a.lower() == 'l' and random1 > random2:
print("Well done")
elif a.lower() == 's' and random1 == random2:
print("Well done")
else:
print("Loser")
所以我想要做的就是將x作爲我的分數。當答案打印出「Well done」時,我希望它將10分添加到我的分數中,然後打印分數。事情是分數似乎重置整個遊戲時間的負載,我希望它可以添加10分或保持不變。有沒有人知道在我的程序中這樣做的方法。我無法想象這會太難,但我只是一個初學者,仍然在學習。目前,我的程序中沒有添加任何分數,只是讓您可以向我展示最簡單/最好的方法。感謝您的幫助:)如何將分數添加到更高或更低的遊戲
請您談一下比分,但沒有嘗試實施評分。 –