NameError: name 'guess' is not defined

willkab6 at gmail.com willkab6 at gmail.com
Sat Mar 22 11:09:18 EDT 2008


I am very new to both programming and Pyhton and while trying to do
some practice using A byte of python an Error pops up on the IDLE
shell. I am using windows XP. PLease see below.
while running:
guess = int(raw_input('Enter an integer : '))

if guess == number:
print 'Congratulations, you guessed it.'
running = False # this causes the while loop to stop
elif guess < number:
print 'No, it is a little higher than that.'
else:
print 'No, it is a little lower than that.'
else:
print 'The while loop is over.'
# Do anything else you want to do here

print 'Done'

After typing the above as the book says, I get the error NameError:
name 'guess' is not defined
What Am I doing wrong?



More information about the Python-list mailing list