When it is asking to play again for 1st time and I enter x, the program ends. But if I continue playing and during the 2nd time, when I enter x, it does not end. Why?
def b():
random_number=random.randint(1, 10)
turn=0
score=100
while True:
try :
num=input("Enter a number between 1 and 10 : ")
array.append(num)
turn+=1
if int(num)>10 or int(num)<1:
print("Please enter a number within valid range.")
if 1<array.count(num):
print("You have entered this number %s time/s"%array.count(num))
if int(num)==random_number:
print("Excellent you found the number in %s turn/s"%turn)
print("Your score is "+str(score))
choice=input("Press enter key to play again or enter x to quit : ")
if choice.lower()=="x":
print("Nice to meet you")
break
else:
b()
score=100
turn=0
elif int(num)>random_number and int(num)>0 and int(num)<11:
print("Go lower")
score-=10
elif int(num)<random_number and int(num)>0 and int(num)<11:
print("Go upper")
score-=10
except ValueError as err:
print("Oh no!, that is not a valid value. Try again...")