Hi Jeff how are you today?
Well about your question... I copy and pasted your code and it worked fine for
me. Well except for in the code bit you posted you forgot to give a guess a
value before it was referred to. So under number = 44 I just wrote guess = 0
and
it worked fine.
But perhaps I'm misunderstanding your question, because I did not get any of
the
errors you mentioned.
Here is what I got
jigenbakuda@jigenbakuda-HP-G50-Notebook-PC:~$ python 6.py
Guess a number between 1 - 100: 45
Too high
Guess a number between 1 - 100: 43
Too low
Guess a number between 1 - 100: 44
Just right
jigenbakuda@jigenbakuda-HP-G50-Notebook-PC:~$
with this code
number = 44
guess = 0
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" )
If I'm misunderstanding your problem, I'm sorry.
----
What is it about you... that intrigues me so?
________________________________
From: Jeff Goodwin <[email protected]>
To: [email protected]
Sent: Thu, March 17, 2011 2:19:17 PM
Subject: [Tutor] Print/Loop Question
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" )
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor