View Single Post
Old Jan 22nd, 2008, 4:02 PM   #19
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Re: My pyguessinggame

Again, not entirely true.

a = 1
while a == 1:
    a = input("A? ")
    if a != 1:
        print "Did this just happen?"

If the user enters the value 2 into the prompt, he/she will get the message: Did this just happen?.
The while loop condition is only tested before it wraps back around to the top.

But we digress further from the problem. It's not your while loop, and it's not the number of guesses. It's the placement of where you decide to print the result that suffers as a result of your program flow. You don't want it inside the while block. It's not part of the while logic. Get er' out of there!
Sane is offline   Reply With Quote