pythoncodepad

Getting EOFError when using online compiler (codepad.org)


I built a very simple addition calculator in python:

#This program will add two numbers entered in by the user

print "Welcome!"

num1 = input("Please enter in the first number to be added.")
num2 = input("Please enter in the second number to be added.")

sum = num1 + num2

print "The sum of the two numbers entered is: ", sum

I haven't setup python yet, so I'm using codepad.org (an online compiler).

I get the following error:

Welcome!
Please enter in the first number to be added.

Traceback (most recent call last):
Line 5, in <module>
  num1 = input("Please enter in the first number to be addeded.")
EOFError

Solution

  • The problem is that, while codepad will run the code for you, it doesn't give you any interactivity (the program fails when it prompts for input, and codepad can't give it any input, so it gets an error). See https://web.archive.org/web/20120104164315/http://pyref.infogami.com/EOFError for a more thorough explanation of the error.

    You really need to just go ahead and install Python and work with it from your local machine. http://www.python.org/download/

    Oh, and good luck learning Python!