Jun-23-2018, 06:54 AM
Hello,
I am trying to create a guessing game that chooses a random number for the player to guess, outputs the number of guesses the player made before guessing correctly, and then asks the player if they'd like to play again (doing this until the player inputs anything but "Y"). I seem to have a snag when it comes to the player choosing whether or not they want to play AGAIN. Input produces no reaction.
Thank you in advance for your help!
I am trying to create a guessing game that chooses a random number for the player to guess, outputs the number of guesses the player made before guessing correctly, and then asks the player if they'd like to play again (doing this until the player inputs anything but "Y"). I seem to have a snag when it comes to the player choosing whether or not they want to play AGAIN. Input produces no reaction.
Thank you in advance for your help!
import random random.seed() count = 1 num = random.randint(1,10) choice = input("Let's play a guessing game! Want to play? (Y/N)\n") guess = int(input("Guess a number between 1 and 10:\n")) while (choice == 'Y') : while (guess != num) : guess = int(input("Guess a number between 1 and 10:\n")) count += 1 print("It took", count, "guesses to guess", num) choice = input("Do you want to play again? (Y/N)\n")