EOF Error while using input() function. Can someone please help me why am I getting this error? the error is : What is your bet ? Traceback (most recent call last): File "script.py", line 4, in <module> bet = input("What is your bet ? ") EOFError: E


import random

money = 100
bet = input("What is your bet ? ")
guess = input("What is your guess? ")
#Write your game of chance functions here

def coin_flip(guess, bet):
  
  print(bet)
  print(guess)
  
  num1 = random.randint(1,2)
  print(num1)
  
  if (guess == "heads" and num1 == 1) or (guess == "tails" and num1 == 2) :
    print("You Won " + bet + "Rupees! ")
  elif (guess == "tails" and num1 == 1) or (guess == "heads" and num1 == 2) :
    print("You Lost " + bet + "Rupees! ")
    
 #Call your game of chance functions here

coin_flip(guess, bet)



1 Like

@osmanshakir, I agree that the input() fuction would be a natural for this assignment, but it seems for some reason that it is not implemented in whatever serves as an interpreter for this particular IDE, but raises an EOF Error!

You’ll need to just provide the values of guess and bet from your script.

I did not get what you are trying to stay. I am using codecademy’s online interpreter. I dont know why the error is showing up? I want to know how do I fix this error? The value of “bet” and “guess” have to be given by the user. I cannot just provide values of these two variables.

That is my point. You must do so, because the editor will not run the input() function! If you read the instructions, it nowhere mentions using input(). As far as I can see, it is a bug in the editor.

2 Likes

Got it!. Thanks a lot bro! Feels great to be helped!

1 Like

Thanks. I’ve noticed that point too. I tried to use input function to have better suite but it is not defined for that project.

Yeah, many of the learners here have stumbled across this issue in one lesson or another at some point.

Not all of the lessons on Codecademy’s Python courses have “interactive” terminals - which is to say that in some lessons, the terminal is output-only and you cannot type into it.

If you try and ask for input on any of these lessons where the terminal is “output-only”, you will get this EOFError because the learning environment cannot accommodate it.

The only workaround is to manually provide whatever values you would otherwise seek from the “user”. :slight_smile:

1 Like