Hi guys, I’m super new to all of this - I’m going through the Python3 course and at the Magic8 ball task I thought I’d try my hand and doing something it didn’t ask me to do, just to see if I could
Ironically, I couldn’t… I wanted to change the question to a user input, rather than a predefined variable using
answer = input("What would you like to ask?: ") and received an EOF error, returning to a pre defined variable makes it work again, I read up on the documentation for Input and for the life of me can’t see where I’m going wrong - I also looked up the EOF error, but the resolutions seemed more advanced for where I’m at.
I was just wondering why input() seems to work fine before this task when I was asked to enter it and what is different now?
Full code below
#import randit function to to the program for randomisation later import random #Standard variables for later ref name = "Harry" question = input("What would you like to ask?: ") answer = "" #Varaible to hold the call to random random_number = random.randint(1, 9) #test random_number output #print(random_number) print(name + " asks " + question) #IF commands checked against random number generated to print a random reply from below preset 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, try again" print("Magic 8's answer: " + answer)
Thanks in advanced