New to Python! Need Help with a simple Guess the number game.
Forgive the dumb question. I'm new to coding, on my 4th day. I have followed a video to program a simple Guess the number game. The video ends with the code ending when the user either guesses the number or failings to guess the number. I would like to get the user's input as to try again or to quit. If they want to try again to get their input and re start the code, if they choose not to try again to end the code. This is what I have so far. I would like to know what I need to do and why. Thank you. while True: print(" Can you guess the number that I'm thinking of? It's between 1 and 10.") secret_number = 3 guess_count = 0 guess_limit = 3 while guess_count < guess_limit: guess = int(input('Guess: ')) guess_count += 1 if guess == secret_number: print('You guessed right!') else: print(" You didn't guess the number I was thinking of.) print(" would you like to try again?") while True: answer = raw_input('Run again? (y/n): ') if answer in ('y', 'n'): break print 'Invalid input.' if answer == 'y': continue else: print 'Goodbye' break