2

I am new to Python and am attempting to write a basic program on my text editor (TextWrangler). I keep getting an EOF error no matter what I do. Here is my code:

print('Hello world!')
print('What is your name?')
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
print('What is your age?') # ask for their age
myAge = input()
print('You will be ' + str(int(myAge) + 1) + ' in a year.')

The error I get is for line 3:

"EOF error: error when reading a line".

I have tried both raw_input and input(), nothing works. What am I doing wrong?

Really appreciate any help on this.

7
  • 2
    I think wherever it is you are running this, it does not support input. I've seen this happen using SublimeText. If you are using SublimeText, install SublimeREPL. That would solve this problem.
    – idjaw
    Jul 10, 2016 at 1:59
  • Line 5 in your code does not contain input . Please post the actual code the actual error message, with full traceback.
    – Selcuk
    Jul 10, 2016 at 2:16
  • Sorry, I meant line 3! My apologies. I edited it. Here is the exact message: Error: File hello.py; Line 3: EOFError: EOF when reading a line Jul 10, 2016 at 2:26
  • Does the error remain if you change input() to raw_input()? Jul 10, 2016 at 2:38
  • 1
    The error does remain, but I have discovered the problem. I was using TextWrangler, and I think the first commenter is correct that it probably does not support "input", because I found the official Python software (version 3.5), installed it, pasted the exact same code into it and it works fine. So I guess TextWrangler is not the best option to use for writing Python programs. Thanks, everyone! Jul 10, 2016 at 2:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.