Help, EOFError: EOF when reading a line, I tried using raw_input(), but then the error showed up

I was making a code that uses the raw_input() function, but then the EOFError showed up. I have another code that uses raw_input(), but the error didn’t show. What did I do wrong?
Here is my code:

from fractions import *

print "The Leaning Tower of Lire Block Counter"

def stack(d):
  a = 1
  n = 1
  a1 = Fraction(a, n)
  a2 = Fraction(a, n * 2)
  while a1 < d:
    if a1 < d:
      x = (a1 + a2)
      a1 = x
      n = n + 1
      a2 = Fraction(a, n * 2)
  return n

d = raw_input("Enter desired tower length: ")

print stack(d)

End of Code

Hello @neofyter. Have you tried running this not on CC? (On a compiler like this one?) The CC learning environment doesn’t like it when you try to retrieve input from the terminal-as I presume a malicious user could drain server power by intentionally not inputting anything. Also, in your old code, did you make sure to have all opening parentheses ( having a matching closing parentheses )? That also causes these errors.
I hope this helps!

1 Like

Some lessons/projects have an interactive terminal which will accept input, others do not.

The EOFError is thrown if someone tries to get input from a terminal which is “output only”. If the OP is running this code in an instance of the LE where the terminal does not accept input, then this would explain the occurrence of the EOFError. :slight_smile:

1 Like