0
input in a loop
I am a newbie, and I am trying to code a little bit. I am getting an error in a quite basic code. My idea was asking for 5 numbers, and prepare a list with them (for future operations). So, I wrote this code, expecting that I could enter 5 numbers in consecutive input boxes. listado=[] for x in range (5): y=input() listado.append(y) print(listado) But I get only this error Traceback (most recent call last): File "..\Playground\", line 3, in <module> y=input() EOFError: EOF when reading a line Any idea? Can't I add this input inside a loop? Thank you in advance for your comments.
3 RĂ©ponses
+ 1
Your code works fine. Your problem is that when you run it in SoloLearn, you're not giving it 5 inputs at runtime. Since it's being processed on SoloLearn's server, you need to input ALL of your inputs at the same time when you run the code.
Here is the results I get with your code:
::::: INPUT ::::::::
1
2
3
4
5
::::: OUTPUT :::::::
['1', '2', '3', '4', '5']
+ 1
Thank you Jakob! I could not find the problem, and it was driving me crazy.
+ 1
You're welcome! Best of luck in your learning.