How do I get the computer to guess by enumeration?
<p>I've only just started using Python so please excuse how bad my code is!</p>

<p>So the computer is playing a game with itself where it has guessed a number between 0 and 100 (target) and it's trying to guess what that number was but it can only guess by enumeration ie. 1,2,3 etc. (i know this isn't the best way for to guess but it's the method I've been asked to show)</p>

<p>This is my code...</p>

<pre><code>print "Let's play a game."
print "I'm going to guess a number between 0 and 100. What is it?" #guess by enumeration
from random import randint
target = randint(0, 100)
print "This is the target number,", target
count=0
while True:

    guess=0
    guess+=1
    count+=1
    print guess 
    if guess == target:
        print ("Well done, you got it! It took you", count, "attempts.")

    break
    else:
        print "You didn't get it that time, try again."
</code></pre>

<p>I'm getting an error when I put this put in. I think there's an issue with the loop and getting the target and guess to equal each other.</p>

<p>This is also the first question I've asked so I'm sorry if this isn't how the questions should be submitted. I'd appreciate any help :-)</p>

<p><code>gess</code> is always equal to <code>1</code> in the while loop, to solve it just move <code>guess=0</code> outside:  </p>

<pre><code>...
guess = 0
while True:
    guess +=1
    ....
</code></pre>

python python-2.7