Reputation: 1
This is the program I've written in PyCharm. It's working fine in the PyCharm IDE but showing an EOF error in Codechef's compiler. Please mention the cause of the error as well as what is an EOF error. Thanks!!
try:
T = int(input())
S = []
N = []
K = []
c = ''
for i in range(T):
x, y = input().split()
N.append(int(x))
K.append(int(y))
ele = input()
ele = ele.split()
for j in range(len(ele)):
ele[j] = int(ele[j])
S = ele
S.sort()
S.reverse()
count = 0
for l in range(N[I]):
if S[l] >= S[K[i]-1]:
count += 1
c += str(count) + " "
print(c)
except EOFError as e:
print(e)
Upvotes: 0
Views: 124
Reputation: 11
It is an interpreter, not a compiler.
An EOF Error is an exception, not an error, common with input(), meaning End Of Line. It is when your input reaches the end of a line.
It is because PyCharm gives input by asking, FORCING you to give input, and if it forces you to give input, it cannot reach end of line as it is not possible as it forces you to give stuff before it reaches the end of the line.
#Be careful with these in CodeChef and be very precise where you put them and do not overuse them.
MyVariable=input()
Some=input()
print("ETC.")
CodeChef does not force you to, so it is allowing you to let it go to the end of the line.
Upvotes: 1