This is my first post ever about programming! Folks, when i execute this algorithm (a guessing game), it doesnt stop asking me for more inputs, even when i write "quit", that was supposed to be the quiting word. The "break" order doesnt work, and i can't find out why. Maybe it works, but when it quits the loop, it executes the "startgame()" at the bottom, but i need this "startgame()" at the bottom to make the game run for the first time, since the game is inside a function and i need to call it to start the game.
import random
def startgame():
a = random.randint (1,10)
cont = 0
while True:
b = input("Guess a number: ")
if b == 'quit':
break
elif int(b) > a:
print("Too high!")
cont += 1
True
elif int(b) < a:
print ("Too low!")
cont += 1
True
elif int(b) == a:
print ("You got it right!")
print ('You needed ',cont,'guesses!')
startgame()
startgame()
Any ideas about how to solve this?