[Tutor] Print/Loop Question

Jeff Goodwin jeffbgoodwin at gmail.com
Thu Mar 17 19:19:17 CET 2011


I'm trying to run the below program and get it to print out feedback as the
loop goes. However, if you enter a number too high or too low, it skips the
print statement under the if and elif clauses and asks the user to "Guess a
number between 1-100" again. Any suggestions on how to get it to print the
"too high" and "too low" responses?? Once the number is entered correctly it
prints "Just Right" and exits correctly.

number = 44

while guess != number :
    guess = int(raw_input("Guess a number between 1 - 100: "))
    *if* guess > number :
        *print* ("Too high")

    *elif* guess < number :
        *print* ("Too low")
    *else*:
        *print* ("Just right" )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110317/2411aff5/attachment.html>


More information about the Tutor mailing list