title: How do you end a python guess number game?
body: <p>i created a loop guess number game with help from @J DawG, but i couldn't figure out how to make it terminate if the user tells it to.  Here's my code:</p>
  
  <pre><code>import random
  
  inplay = 0
  x = ""
  def in_play():
      global inplay, guessesTaken
      guessesTaken = 0
      if inplay == True:
          play()
      else:
          inplay = True
          play()
  
  def play():
      global guessesTaken
      print('Hello! What is your name?')
      myName = input()
  
      number = random.randint(1, 20)
      print('Well, ' + myName + ', I am thinking of a number between 1 and 20.')
  
      while guessesTaken &lt; 5:
          print('Take a guess.') 
          guess = input()
          guess = int(guess) or str(guess)
          guessesTaken = guessesTaken + 1
  
          if guess &lt; number:
              print('Your guess is too low.') 
  
          elif guess &gt; number:
              print('Your guess is too high.')
  
          elif guess == number:
              break
  
      if guess == number:
          guessesTaken = str(guessesTaken)
          print('Good job, ' + myName + '! You guessed my number in ' + guessesTaken + '   guesses!')
          in_play()
  
      elif guess != number:
          number = str(number)
          print('Nope. The number I was thinking of was ' + number)
          in_play()
  
  
  in_play()
  </code></pre>
  
  <p>So yeah, if you could please answer this relatively soon, it would be great.</p>