Skip to content Skip to sidebar Skip to footer

Greeting Program

I have been learning how to program in Python using the book 'Python the Absolute Beginners Guide.' The problem I am having is that when using eclipse-pydev it won't allow me to us

Solution 1:

Use raw_input instead of input.

Python developers probably should have renamed those functions so it's more clear and beginners don't get confused so easily.

When you type caleb into the prompt with input it's trying to evaluate caleb which looks like a variable. The variable caleb hasn't been defined, so it's raising that exception.

Solution 2:

The reason is that you are using the input function which expects that the user will input a string that can evaluate to a python expression. Try changing it to raw_input which will not try to eval, but rather give you a raw string. Also, try just doing your print statement like: print "Hello", name You were missing a comma sep in that first example.

Solution 3:

>>> help(input)

input([prompt]) -> value

Equivalent to eval(raw_input(prompt)).

Use raw_input.

Post a Comment for "Greeting Program"