Word input



So this keeps appearing when I enter any word:

Welcome to the Pig Latin Translator!
Enter a word: hello
Traceback (most recent call last):
File "python", line 3, in
File "", line 1, in
NameError: name 'hello' is not defined

I think it has something to do with the python version being utilized. I arrived at this conclusion because I had to use input() instead of raw_input() for the code to run.

Any help on this matter will be greatly appreciated.

print "Welcome to the Pig Latin Translator!"

original = input("Enter a word: ")


in python2 (which codeademy uses), unless you have a really good reason not to, use raw_input()

using input() in python2 is like using eval(input()) in python3, which will parse the user input and evaluated as a Python expression


In this version, Python 2.7.x, we use raw_input for strings. We cannot see enough of your code to determine the error.


The code won't run if I use raw_input.


Can we see your full code using raw_input with markup:

Then we can see why the code is not running


Did you do something? I tried once again with raw_input (for like the millionth time) and now it worked perfectly! You're sneaky... >> Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.