Can't run this program in atom


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/pyglatin/exercises/testing-testing-is-this-thing-on-?action=lesson_resume&link_content_target=interstitial_undefined

<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?

```python

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

else:
print ‘empty’

<do not remove the three backticks above>

#2

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())


#3

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?


#4

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)


#5

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