I always get this error whenever using input() in Python3 in any online compiler, hackerrank, wipro portal, interviewbit etc. I've seen so many posts regarding this, but none of them is working for me. try except block leads to always execution of the except block which I don't want as I'm still not able to read any input. Even as simple as the following code doesn't work. Help.
b = int(input())
print (b)
I get the following error:
Traceback (most recent call last):
File "main.py", line 227, in
Z = obj.solve(A)
File "/tmp/judge/solution.py", line 9, in solve
b = int(input())
EOFError: EOF when reading a line
Try going to https://www.hackerrank.com/challenges/python-loops/problem where the single input line is already there in the starter code for you. If you select Python 3 from the language dropdown, and then -- without entering any code of your own at all -- click Run Code, you should get a Wrong Answer "no response on stdout" response. Do you get that, or do you still get an EOFError? I'm assuming you don't get the EOFError and that perhaps there's a problem with where/how you're entering your code into their editor.
If you're getting an error like that with InterviewBit, I'd say it's because with InterviewBit you're not supposed to be reading from stdin at all -- the starter code will have a function that their test cases call, and then you complete the function code to return the desired output.