When I use input() directly in the print, why do I get the error EOF when reading a line at Answer.py?

Hi everybody,
I am facing a problem in online IDE of clash of codes.
In python I was using this code:
print(int(input(),16))
But it shows the error EOF when reading a line at Answer.py
when I break down above code into two lines:

n=int(input())
print(n,16))

This code works fine. So I presumed I cannot use the first version in the online IDE. But I saw code from other clash of code users they were using the first version!
In every clash, when I use input() directly in the print, why do I get the error EOF when reading a line at Answer.py?

The function input reads and consumes a line of input and returns it as a string.
If you have a single line of input, consume it and use input again, you get this EOF (end of file) error.
So basically, if you need to ‘go back’ to the input, store it in a variable.
Else, you don’t have to.

Your first piece of code is valid as long as you didn’t already consumed the input.
Your second piece of code is weird, the ,16 should be within the int (to read as hexadecimal) and there’s a useless ).

1 Like

Thanks for the reply.
I am relatively new to python and I did not completely understand your response. But the code is exactly the same which other people were using and they got 100% in the clash of code.

I still don’t understand how they could use that code and I could not.

It’s impossible to point out the exact problem there was in your code without a full code.
If it happens again, share the full code and we’ll tell you what’s the problem.

But there are no bugs with Python in CG IDE so the problem was in your code.
You probably thought that the code was doing exactly the same as others but there was necessarily a difference you missed.
You had a additionnal input() somewhere that tried to read a line that was already consumed, the error message is formal. You cut the end of the error message but it was normally telling you the line in your code when it occurs.
If you want to reproduce the error, open any puzzle, add an input() after the one(s) written in the stub, and you’ll get the same exact error message.

2 Likes