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.

number = 30
guess == int(raw_input("enter an integer:"))
if guess == number:
    print "congratulations, you ar a genius."
    print "Do not get a bog head though."
elif guess < number:
    print "you need to guess higher."
else:
    print " No it is a little lower than that."
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?

guess == int(raw_input("enter an integer:"))

should be

guess = int(raw_input("enter an integer:"))

If you try to assign a value to a variable using '==', you will return a Boolean data validity confirmation ;), that is to say, it will return True if the two variables are the same and False if not.

Chew on this;

import random as rand
number = rand.randint(1,1000)
guess == int(raw_input("Enter an integer: "))
while True:
    if guess == number:
        print """Congratulations, you are a genius.
Do not get a bog head though."""
        break
    elif guess < number:
        print "You need to guess higher."
    elif guess > number:
        print "No it is a little lower than that."
print "Done"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.