Magic8 Ball Exercise: eof error in python input()

EOF error shows up when input() is invoked.

magic8

import random name = 'Jordanz' questions = "Is there EOF error for input()?" random_number = random.randint(1, 9) if random_number == 1: answer = ('Yes - definitely.') elif random_number == 2: answer = ('It is decidedly so.') elif random_number == 3: answer = ('Without a doubt.') elif random_number == 4: answer = ('Reply hazy, try again.') elif random_number == 5: answer = ('Ask again later.') elif random_number == 6: answer = ('Better not tell you now.') elif random_number == 7: answer = ('My sources say no.') elif random_number == 8: answer = ('Outlook not so good.') elif random_number == 9: answer = ('Very doubtful.') else: answer = ('Error. Number out of range.') name = input('Your name please: ') print(name, 'asks: ', questions) print("Magic 8-Ball's answer: " + answer)

Hey there :wave: Welcome to the forums!! :slightly_smiling_face:

Odds are in this particular lesson, the console wasn’t built to handle input, which is why you would get an end of file error. Best option would probably be to hard code a value for questions.

1 Like