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?

13th Nov 2016, 4:54 AM
Adam L
Adam L - avatar
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?
13th Nov 2016, 2:57 PM
Kirk Schafer
Kirk Schafer - avatar
+ 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?
13th Nov 2016, 3:28 PM
Kirk Schafer
Kirk Schafer - avatar
+ 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.
13th Nov 2016, 3:34 PM
Kirk Schafer
Kirk Schafer - avatar
+ 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.
13th Nov 2016, 3:40 PM
Kirk Schafer
Kirk Schafer - avatar
0
i think you must make input user first,after that make looping and for end make print command
13th Nov 2016, 7:03 AM
omi
0
I die Not do Python but I Think you have to break the Code
13th Nov 2016, 7:04 AM
TheSimonLP YT
TheSimonLP YT - avatar
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.
13th Nov 2016, 3:02 PM
Adam L
Adam L - avatar
0
To KirK Schafer: I'm using the Code Playground in this app.
13th Nov 2016, 3:31 PM
Adam L
Adam L - avatar
0
To Kirk Schafer: There are only two lines of code, and I did press enter after each line...I think.
13th Nov 2016, 3:37 PM
Adam L
Adam L - avatar
0
To Kirk Schafer: That worked. Thanks!
13th Nov 2016, 3:51 PM
Adam L
Adam L - avatar