lowerBound = 1 upperBound = 1001 guess = 500 count = 0; correct = False; pastGuess = [0] * 10 print "Think of a number between 1 and 1000" print "Options: equal, greater, less" question = raw_input("Is the number equal, greater than, or less than " + str(guess) +"?\t") while(count < 10): if(question.lower() == "less"): pastGuess[count] = guess; upperBound = guess; guess = ((upperBound - lowerBound) / 2) + lowerBound if(guess) in pastGuess: break elif(upperBound - lowerBound == 0): break elif(question.lower() == "greater"): pastGuess[count] = guess; lowerBound = guess guess = ((upperBound - lowerBound) / 2) + lowerBound if(guess) in pastGuess: break elif(upperBound - lowerBound == 0): break else: print "Enter correctly" count -= 1 print "Options: equal, greater, less" count += 1 question = raw_input("Is the number equal, greater than, or less than " + str(guess) +"?\t") if(question.lower() == "equal"): correct = True break if(correct == True): print "I win" elif(correct == False): print("You lied.")