Script(Python) Doesn't allow inputs?


I just started learning how to code on codeacademy, and one of the things you have to make there is a pig latin translator.

I tried making it on Atom today, and got this error:

Traceback (most recent call last):
  File "/home/musse/Programming/Python/Tests/", line 5, in <module>
    word1 = raw_input("Please enter the word you desire to translate:")
NameError: name 'raw_input' is not defined
[Finished in 0.326s]

This is my code:

# The pig latin translator

pig = "ay"

word1 = raw_input("Please enter the word you desire to translate:")
if len(word1) > 0 and word1.isalpha():
    word2 = word1[1]
    word3 = word1 + word2 + pig
    word3 = word3[1:len(word3)]

    print("The word you've enter is not accepted. Please try another one.")



No. This question has been asked a lot, so you will find plenty of good answers on how to get around that:


raw_input() is Python 2 syntax, so this is what you get when you use a Python 3 interpreter.

Always remember:

Python 2: input() == Python 3: eval(input())
Python 2: raw_input() == Python 3: input()


@seanmusse To clarify: your code is failing because your syntax is the wrong version of Python for the interpreter, but the script package also doesn’t allow for inputs.


I had tried it using input() but got the same result, but thank you! :slight_smile:


Both of them give the same error :confused:


Thank you!