-3

I've got this code:

while True:

a=0
b=1
l=[]
N=int(input())

chk=0
for k in range(N):
    l.append(0)


for i in range(N):
    a,b=b,a+b
    l[i]+=b

for j in range(len(l)):
    if l[j]==N:
        chk=1
        break

if chk==1:
    print("Isfibo")
else:
    print("Isnotfibo")

When I run it on IDLE it gives me the required output but if I try to use this same code on hacker rank it gives a runtime error and

it says

Nice try, but you did not pass this test case.

Input (stdin)
3
5
7
8

Your Output (stdout)
Isfibo
Isfibo
Isnotfibo
Isfibo

Expected Output
IsFibo
IsNotFibo
IsFibo

Compiler Message
 Runtime Error
Error (stderr)

Traceback (most recent call last):

  File "solution.py", line 6, in <module>
  N=int(input())

EOFError: EOF when reading a line
Thom Wiggers
  • 6,938
  • 1
  • 39
  • 65
  • possible duplicate of [Python 3: EOF when reading a line (Sublime Text 2 is angry)](http://stackoverflow.com/questions/12547683/python-3-eof-when-reading-a-line-sublime-text-2-is-angry) – Maroun Feb 01 '15 at 07:46
  • That is not a correct duplicate, even though the error message is the same. @MarounMaroun – tripleee Feb 01 '15 at 08:15
  • 1
    Just **look** at the message. You aren't matching the case, and have the wrong number of test cases. Re read the spec. – jonrsharpe Feb 01 '15 at 08:45

1 Answers1

0

It looks like the first number is a count of how many data values follow, and not a number to test for being a Fibonacci number.

As a total quick-n-dirty fix, you could replace the while True: statement with:

for n in range(int(input)):

That will input a value, loop for n=0 to (that value)-1, then stop. That will give you the desired output on that particular data.

Mike Housky
  • 3,959
  • 1
  • 17
  • 31