Python 3.5 While loop not entering the If Statements
<p>My apologies in advance. I know this question has probably been asked on stack exchange before and I do see some relevant posts,but I'm having some issue interpreting the responses.</p>

<p>I've been asked to create a guessing program that uses 'bisection search' to guess the number that you've selected (in your mind).</p>

<p>I have a program that runs on Python 2 interpreters when I change input() to raw_input(). My program also runs on a python 3 interpreter (python tutor). However when I run the program from scipython, pycharm or command line I do not see the response I'm expecting. Instead of moving through the if statements under the while loop the program seems to loop through the top of the while statement over and over again. I'll paste my code any suggestions would be appreciated.</p>

<pre><code>low = 0
high = 100
flag = True

print("Please think of a number between 0 and 100!")
while flag:
    ans = (high + low) // 2
    print("Is your secret number " + str(ans))
    question = input(
    "Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")
    if question == 'l':
        low = ans
    elif question == 'h':
        high = ans
    elif question == 'c':
        flag = False
        print("Game over. Your secret number was: " + str(ans))
    else:
        print('invalid response, please choose again.')
</code></pre>

<p>EDIT:
This is the output to console. There is no failure but as you can see the program is not entering the if conditionals. I entered the response to each conditional and it just returns the same guess. I assume that I'm not entering the if statements because I do not get a change to the answer or if I hit an incorrect character, I do not get to the else: print.</p>

<pre><code>Is your secret number 50
Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. l
Is your secret number 50
Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. h
Is your secret number 50
Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. c
Is your secret number 50
Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. 
</code></pre>

<p>EDIT #2:
I just got it to work for some random unknown reason. scipython still won't run the code correctly, but the grading program marked me correct. So frustrating! </p>

<p>Ok I figured it out after my code graded correctly. I was using the wrong console in scipython IDE to evaluate my code D'Oh</p>

<p>Anyways the code is a good example of taking an input() inside a while loop and using if/elsif/else to meet conditions.</p>

<p>Just remeber that in python 2 you'll want to use raw_input() instead of input() as the method changes from python 2 to 3</p>

python python-3.x bisection