Newbie: Explain My Problem
sjmachin at lexicon.net
Wed Jun 29 11:42:13 CEST 2005
ChuckDubya at gmail.com 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