so I am trying to make a guessing game on my own and when the game ends I hope it will prompt the player if he wants to play again by typing yes or no like this:
Guess a number between 1 to 10: 7
YOU WON!!!!
Do you want to continue playing? (y/n) y
Guess a number between 1 to 10: 7
YOU WON!!!!
Do you want to continue playing? (y/n) n
Thank you for playing!
I managed to get the game working but I can't play the game again. I am stuck here:
guess = int(input("Guess a number between 1 and 10: "))
while True:
if guess > num:
print("Too high, try again!")
guess = int(input("Guess a number between 1 and 10: "))
elif guess < num:
print("Too low, try again!")
guess = int(input("Guess a number between 1 and 10: "))
else:
print("You guessed it! You won!")
replay = input("Do you want to continue playing? (y/n) ")
if replay == "y":
**what to insert here???**
else:
break
I don't know what to type inside the if statement that will return my code to the top of the loop if the user press "y" and allows me to restart the game.
Any help will be appreciated! Please do not give me the entire solution but try to give me hints so I can solve this by myself! Thank you!
Aucun commentaire:
Enregistrer un commentaire