0

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).

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Sang
  • 11
  • 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 Nov 13 '19 at 00:10
  • 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 Nov 13 '19 at 00:22

1 Answers1

0

Perhaps you can handle there exception with try and except:

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