Can't run this program in atom



<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

Traceback (most recent call last):
File “C:\XXX”, line 3, in
original = raw_input(‘Enter a word:’)
NameError: name ‘raw_input’ is not defined
<What do you expect to happen instead?>
why this program run smoothly on the online playground but not on atom?


pyg = ‘ay’

original = raw_input(‘Enter a word:’)

if len(original) > 0 and original.isalpha():
word = original.lower()
first = word[0]
new_word = word + first + pyg
new_word = new_word[1:len(new_word)]

print new_word

print ‘empty’

<do not remove the three backticks above>


running a program atom is always very tricky, atom is a text-editor, its not capable of actually executing a program.

If you use python3, you need to use input() function.

python2 has two functions: raw_input and input. raw_input function ask the user for input and stores the result as a string, input function evaluates the input as code

in python3, raw_input function got renamed to input. If we want the users input evaluated as code in python3, we can use eval(input())


Thank you for your reply,

But it become

Enter a word:Traceback (most recent call last):
File “C:\Users\nam\Desktop\testing”, line 3, in
original = input(‘Enter a word:’)
EOFError: EOF when reading a line

after i change raw_input to input…
what’s the problem?


EOFError shows up when you try to read after input has been closed (end of input file) - so perhaps there’s no terminal/equivalent connected to your program’s input. Whatever you’re running it from might not intend to provide a way of doing user input. (Or maybe it does, I have no idea what you’re doing, just what the error means from python’s perspective)


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