0
votes

Why does my program work in PyCharm but in online interpreter gives this error:

Traceback (most recent call last): File "Solution.py", line 4, in s = input() EOFError: EOF when reading a line

Here's the part of code that matters:

i = 0
while True:
    s = input()
    if s == '':
        break
    else:
        ...

I'm trying to input strings until empty string occurs but it always gets stuck on line with empty string. Thanks in advance and sorry if I'm sloppy with my question (my 1st question).

1
If there's a problem with an online interpreter running this code, please link to it. My first guess would be that it doesn't support input(), but it's impossible to tell without any further information. - Seb
We need your posting to reproduce the problem at hand. If I add a simple pass command for the missing else clause, the code operates as expected. Your error message suggests that the source file abruptly ends at line 4. - Prune

1 Answers

0
votes

Perhaps you can handle there exception with try and except:

while True:
    try:
        s = input()
        ...
    except EOFError:
        break
...