Python, Error while taking input

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.

Thanks you explained really well :+1:

I provided custom input and the code worked. But now, while submitting it is causing Re(NZEC) Error.

3 Likes

bro, my code is working well and good with custom inputs but as i submit it shows either wrong answer, when i put it in the try/catch block or that runtime error (EOF error).

bro, my code is working well and good with custom inputs but as i submit it shows either wrong answer, when i put it in the try/catch block or that runtime error (EOF error).
why so?

Codechef doesn’t provide custom input in ide ,Thats why you get NZEC,

I think what you are doing is writing a code where you are supposed to give the compiler some input but ain’t supplying one.

If your code needs input, you need to give that to it by using the custom input. Or in case of submitting, codechef give its own test cases as input. I think this might be the issue here.

Using the RUN command without custom input will just give you NZEC. You may browse internet for the possible reasons why NZEC occurs for a program.
Here’s a link : https://www.geeksforgeeks.org/nzec-error-python/

Correct me if i am wrong.

Custom inputs are working fine but on submission it shows runtime error

1 Like

Then your code is broken. A RTE does not always mean a EOF error