Word input


#1



https://www.codecademy.com/courses/python-beginner-2W5v7/0/3?curriculum_id=4f89dab3d788890003000096


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: ")


#2

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


#3

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


#4

The code won't run if I use raw_input.


#5

Can we see your full code using raw_input with markup:

Then we can see why the code is not running


#6

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!


#7

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