Python 3: Traceback : TypeError
<p>I'm new in python 3 and I don't understand why I get a Type Error (this is a guess a number game for numbers between 0-100):</p>

<pre><code>print("Please think of a number between 0 and 100!")
low = 0 
high = 100
check = False
while True :
    guess = (low + high)/2
    print("Enter 'h' to indicate the guess is too high.\n")
    print("Enter 'l' to indicate the guess is too low.\n" )
    print("Enter 'c' to indicate I guessed correctly.\n")
    ans = input("")  
    if ans == "h" :
        low = ans
    elif ans == "l" :
       high = ans
    elif ans =="c" :
        print( "Game over. Your secret number was:{}".format(guess))
        break
    else :
        print("Sorry, I did not understand your input.")
</code></pre>

<p>here is the error : </p>

<pre><code>Traceback (most recent call last):
 File "&lt;stdin&gt;", line 1, in &lt;module&gt;
</code></pre>

<p>Thanks in advance.I'd really appreciate your help I'm stuck in this</p>

<p>A couple of things. </p>

<ol>
<li>You should probably print the guess so that the user knows whether it is too high or too low</li>
<li><code>low==ans</code> doesn't make any sense. <code>ans</code> will either be "h", "l", or "c", assuming the user follows the rules. <code>low</code> and <code>high</code> need to be numbers in order to generate the <code>guess</code>  appropriately</li>
</ol>

<p>Also your logic was incorrect. The below code works. </p>

<pre><code>print("Please think of a number between 0 and 100!")
low = 0
high = 100
check = False
while True:
    guess = (low + high)/2
    print("My guess is: %i" % guess)
    ans = input("Enter 'h' if guess it too high, 'l' if too low, or 'c' if correct: ")
    print(ans)
    if ans == "h":
        high = guess
    elif ans == "l":
        low = guess
    elif ans == "c":
        print("Game over. Your secret number was:{}".format(guess))
        break
    else:
        print("Sorry, I did not understand your input.")
</code></pre>

python typeerror traceback