Newbie: Explain My Problem

John Machin sjmachin at
Wed Jun 29 11:42:13 CEST 2005

ChuckDubya at wrote:
> while counter != 0:
>     if guess == num:

Others have told you already what was wrong with your program. Here's a 
clue on how you could possibly help yourself:

1. Each time around your loop, print the values of the interesting 
objects, in this case counter and guess.
    E.g. before the "if" statement above, put something like this:
    print "guess = %r, counter = %r" % (guess, counter)
    That would have shown "guess" containing a string e.g.
    guess = '42', counter = 4
    instead of an integer e.g.
    guess = 42, counter = 4

2. Examine the logic carefully. The answer to your second problem was 
just staring you in the face -- you hadn't pulled the ripcord after the 
counter became zero.


More information about the Python-list mailing list