Python, Error while taking input

I am trying to submit #BSTOPS using python3. My code is working perfectly fine with custom input but i am getting runtime error on submission. Please help.

2 Likes

Seems like something is wrong with your code.

1 Like

Remember to select PYTHON (3.x) when you are using ā€œinput()ā€ instruction.
Try the sample test case in CUSTOM input and then just submit the code.
On Submission it works fine but when you try to RUN, it will show the following:
NZEC
EOF at line(x)
So I would suggest to use CUSTOM input to RUN your code and then just SUBMIT the code.

4 Likes

thanks, it works

I have observed that this problem occurs only when taken input of two or more numbers separated by space. When I program in Java, it recognises them as two separate numbers, but in python it assumes the form of a string, say ā€˜x yā€™. The program does not throw an error when only a single number input is required.
As a workaround, use the following,
a, b = map(int, input().split())

// This is my first answer in CC forum, please like if it helped.

4 Likes

I was also facing the same issue. But Somewhere i saw a comment to switch to Non IDE Mode .
And that worked for me.

Hello there! I too faced the same problem but now rectified it up.
Include your input statement within a try block and catch the exception error raised as follows:

try:
** n = int(input())**
except EOFError:
** pass**

The above error is raised because when you reach the end of the input, input will read nothing. So the error is raised. Do check it out and let me know if still errors are there.

donā€™t worry much about it just run your code on custom inputs its giving right output you can submit it it will get AC.

this worked for me ty

t = int(input())
above try and except block skips this inputā€¦so i canā€™t use the variableā€¦
can you please provide another alternative to get rid of this EOFErrorā€¦

Declare t as a global variable and useā€¦your problem happens because when u donā€™t declare it global, when u come out, it goes out of scope

this worked for me.

This solution worked for me

Thanks

tried all above ways
still facing this error
custom input works successfully
but run and Submit shows this same error

Hey! Write your code as follows :
t = 0
try:
t = int(input())
except EOFError:
pass

1 Like

Thanks a lot , i have been looking for this ā€¦
Python noobā€¦

dude! if u are running your code without providing Input this error will occur.
You will have to provide custom input to remove this.

thanks, this worked for me

t=map(int,input().split())

Yes Thanks, It works fine.