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")
So what I am trying to do is have x as my score. And when the answer prints “Well Done” I would like it to add 10 points to my score and then print the score. The thing is the score seems to reset loads of times throughout the game and I would like it to either add 10 to the score or stay the same. Does anyone know a way of doing this in my program. I can’t imagine it would be too hard but I am only a beginner and still learning. At the moment I have no score at all added to my program, just so you can show me the easiest/ best way too approach this. Thanks for the help 🙂
anyway, the whole code could be shortened to: