title: Python 3.1 number guessing game higher or lower loop
body: <p>In the process of learning Python using the book 'Python Programming for the Absolute Beginner Third Edition' and struggling with a challenge that has been set.</p>
  
  <p>I have to create a Number Guessing program where the player picks a number and the program tries to guess it by picking a random number then using higher or lower questions to get closer to the number. I've got most of it figured out but I'm struggling with the higher or lower loop. The trouble I'm having is that i can't get the program to not go above or below it's second to last guess i.e.</p>
  
  <p>My number is 78
  computer picks 50
  i say higher
  computer picks 80
  i say lower
  computer can then pick 12 (when i don't want it going below 50.</p>
  
  <p>I'm using Python 3.1</p>
  
  <p>Here is a copy of the code.</p>
  
  <pre><code>import random
  
  computer_tries = 0
  player_number = None
  computer_guess = random.randint(1, 100)
  
  print(
      """
      Welcome Player to the fabulous number guessing game.
      Please allow me to show you my incredible deduction skills
      """)
  
  question = None
  while question != ("yes"):
      question = input("Has the player picked a number? ")
      question = question.lower()
      if question == "yes":
          print("\nI will now guess your number!!!\n")
          while player_number == None:
              computer_tries += 1
              print(computer_guess, "\n")
              confirmation = input("Is this the correct number? ")
              confirmation = confirmation.lower()
              if confirmation == "yes":
                  player_number = computer_guess
                  if computer_tries &lt; 2:
                      print("I did it! I guessed your number was", computer_guess,
                             "and it only \ntook me", computer_tries,
                             "try to get it right!")
                  else:
                      print("I did it! I guessed your number was", computer_guess,
                             "and it only \ntook me", computer_tries,
                             "tries to get it right!")
              else:
                  higher_lower = None
                  while higher_lower not in ("higher", "lower"):
                      higher_lower = input("Is my guess higher or lower"
                                  + " than your number? ")
                      higher_lower = higher_lower.lower()
                      if higher_lower == "higher":
                          higher = computer_guess
                          computer_guess = random.randint(higher, 101)
                      elif higher_lower == "lower":
                          lower = computer_guess
                          computer_guess = random.randint(0, lower)
                      else:
                          print("Please choose either higher or lower.")
  
  
  
  input("\n\nPress the enter key to exit")
  </code></pre>
  
  <p>Thanks in advance for any help you folks can give.</p>
  
  <p>Ally</p>