0
Why can't I put inputs in loops?
I am getting an End Of File error using this code: for I in range(5): test = input("test") Why?
10 Respostas
+ 1
Is it possible you changed your code for posting, and the error you're getting (due to what was an unterminated string literal) is effectively this?
>>> for I in range(5):
... test = input("test
File "<stdin>", line 2
test = input("test
^
SyntaxError: EOL while scanning string literal
because your code works for me. At what point does EOF (vs the EOL above) occur?
+ 1
...running from an IDE? Sublime Text for Mac requires an add-on. From command line with a pipe? What OS? Python 3.x I assume?
+ 1
Enter all 5 lines at once. Press enter after each line.
It's a limitation of the playground...although it's a good example of running past EOF.
They're probably using a pipe or temporary file to send input.
+ 1
All 5 lines of input, at the prompt. You'll see "testtesttesttesttest" in the output area if accepted.
edit: unless you're not getting prompted. That would be a bug...maybe from a previous code snippet redefining something (that might indicate a security violation). You could try restarting the app.
0
i think you must make input user first,after that make looping and for end make print command
0
I die Not do Python but I Think you have to break the Code
0
To Kirk Schafer: It occurs on the input line, and definitely returns an EOFError.
To TheSimonLP YT and omi: Those solutions don't cause my intended result, which is running the input command the number of times the loop runs.
0
To KirK Schafer: I'm using the Code Playground in this app.
0
To Kirk Schafer: There are only two lines of code, and I did press enter after each line...I think.
0
To Kirk Schafer: That worked. Thanks!