EOF when reading line

Hello.
Why is this code from the Games of Chance ‘Heads or Tails’:

def flipping_coin():
  bet = input('How much are you betting? ')
  outcome = input('Heads of tails? ')
  outcome.lower()
  bet = int(bet)
  coin = round(random.randint(1, 2))
  if coin == 1 and outcome == 'heads':
    print('You won! You won this much ' + str(bet) + ' congratulations!')
    money += bet
    return money
  elif coin == 2 and outcome == 'tails':
    print('You won! You won this much %d congratulations!') % (bet)
    money += bet
    return money
  else:
    print('You lost! You lost this much ' + str(bet) + ' bad luck!')
    money -= bet
    return money
flipping_coin()

throwing this error:

Traceback (most recent call last):
  File "script.py", line 24, in <module>
    flipping_coin()
  File "script.py", line 7, in flipping_coin
    bet = input('How much are you betting? ')
EOFError: EOF when reading a line

I have tried putting the input() for both bet and outcome outside the function. It threw the same error.
Thank you sincerely!

codecademy learning environment doesn’t always allow using input(), what happens when you run this code on repl.it or anywhere else?

It works! Thank you very much for your help!

1 Like

Thank you for getting to the problem before I did.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.