Why is this not working ?(working in 3.5.1)........HELP PLZ


a=input("enter the english word ")
if (a.isalpha()==True):
    print("the pig latin of the word is ",a[1:]+a[0]+'ay')
    print("this is not a word ")


@anon1221: Hello, sachin!
Here's a post on stackoverflow that talks about your error and the difference between input and raw_input (considering the Python version's 2.7.x and 3.x)

Python input() error - NameError: name '…' is not defined

Edit: I've decided to post the link since it's well explained.


I ran your code in a python shell(3.5.1):

With one additional command, to check that the user input is a string, which it is, then the code works fine, what does the error message indicates?


@stetim94: I ran his code and got an error message similar to this one:

line 1, in <module>
input_variable = input ("Enter your name: ")
File "<string>", line 1, in <module>
NameError: name 'dude' is not defined


How is that possible? I copied the code, line by line (and even as a whole and put it in a script), ran it in python 3.5.1 (which anon1221 says he is using), and in both cases it ran fine, what is causing our differences?

command: cat test.py, output:

a=input("enter the english word ")
if (a.isalpha()==True):
    print("the pig latin of the word is ",a[1:]+a[0]+'ay')
    print("this is not a word ")

then i did the following command: python test.py which gave:

enter the english word test
the pig latin of the word is  esttay

Again, what causes our differences?


What's the Python version we are currently using on Codecademy?
According to what I read, there's a difference between one version to another when it comes to input and raw_input


codecademy use 2.7 or so, but anon1221 says in the title of his question: working in 3.5.1, so i ran the code in 3.5.1


Hmm, I guess he tried to use a Python code who's version is 3.5.x here and, once again, according to the post input and raw_input are not the same thing, until version 3.x

Edit: I'm considering the idea of anon1221 using that exact same code on Codecademy, not on another website or IDE or something.


Oh, i think you are right.... Stupid me. Working in 3.5.1 can also mean: This code works in python 3.5.1 but not here on codecademy. Seems i need coffee. Then you are right, input and raw_input are different


thanks @g4be and @stetim94