Why do some online Python compilers not allow me to enter an input?

Viewed 213

I found quite a few examples of how to use input in Python 3. I even directly copied examples from videos to online python compilers and I always get an EOF error on the input line.

For example:

password = input("please enter password... ")

it won't even let me put an input and end the program. Did a rule change?

1 Answers

No, the input rules did not change.

It's just those type of online Python interpreters expect you to provide the input values before you actually run the program. There is no prompt for the input value, where they wait for you to enter something. Instead, they automatically read what you put for STDIN and then pass it to your program.

In https://onecompiler.com:

OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab.

onecompiler example

In https://www.tutorialspoint.com:

tutorialspoint example 1

tutorialspoint example 2


I would say it's better to learn how to run your programs locally, especially if you are writing programs that get or read multiple user inputs. For example, in the images above, you'll have to add some unnecessary code to print out the name on a separate line or to handle multiple input's. On local, the same code works (and looks) better:

$ cat main.py
name = input("What's your name? ")
print(name)

$ python3 main.py
What's your name? gino
gino
Related