from random import randint wantsToPlay = True # will play at least one time while wantsToPlay: # play the actual game secret = randint(1,100) guess = int(raw_input("Guess the number: ")) while guess != secret: # wrong answer if guess > secret: print "No. Lower" elif guess < secret: print "No. Higher" # get a new guess guess = int(raw_input("Guess the number: ")) print "Yes. Congratulations" # does user want to play again? response = raw_input("play again? ") wantsToPlay = response.lower() in ('y','yes') print 'Thanks for playing. Goodbye'