Is there a way to run code requiring user input? [EOFError: EOF when reading a line]


#1

I set up Atom last night, and am using Zelle’s “Programming” book to learn code. Everything was fine until I wrote the following:

def main():
    print ("This program illustrates a chaotic function")
    x = eval(input("Enter a number between 0 and 1: "))
    for i in range(10):
        x = 3.9 * x * (1 - x)
        print (x)

main()

I received the following error:

This program illustrates a chaotic function
Enter a number between 0 and 1: Traceback (most recent call last):
  File "C:\Users\Alex\Desktop\Programming\testing.py", line 8, in <module>
    main()
  File "C:\Users\Alex\Desktop\Programming\testing.py", line 3, in main
    x = eval(input("Enter a number between 0 and 1: "))
EOFError: EOF when reading a line

Looking this up, I saw discussions from 2015 indicating that Atom does not support user input. This sounds odd to me, however. Is there a way to either change my present settings or add a plugin that allows user input? I like Atom quite a bit, and much of Zelle has prompts similar to those above.

I was told to try some of the script plugins, or run the code from a terminal window. I downloaded the most popular “script” plugin, but when it’s run, I simply get:

This program illustrates a chaotic function

with nothing else, and no room for input. Since I’m just starting out, I don’t even know whether I’m running it correctly.

There is also “add a terminal panel” at the bottom of the screen, and when clicked, I get:

input your command here

But what do I input there? How does this interact with the code as written, if at all?

Thank you.


#2

Atom doesn’t support building or executing code directly in Atom out of the box. There’s a FAQ about it here:

There are some Atom packages that some have reported success using in building or executing code from within Atom. I stopped recommending the script package because it appears that it is no longer supported.

While the script package may not support user input, Atom itself does, as can be proved by the large number of Atom packages that allow it, for example:

And many others.

My typical recommendation is to build and execute code from the terminal.


#3

Thanks, I’ll try that.