0

Why does it say the 'forename' variable is not defined? code in description

try: forename = str(input("Please tell us your first name: ")) except EOFError as e: print(e) try: Surname = str(input("Please tell us your surname: ")) except EOFError as q: print(q) print("Hello",forename,Surname) #tells us full name which was inputted def hru(str): #The function which asks how are you howareyou = str(input("How are you? ")) if howareyou == "Good": print("Glad to hear that" ,forename, ":D") ocul(str) elif howareyou == "good": print("glad to hear that" ,forename, ":d") ocul(str) elif howareyou == "Fine": print("Good :)") elif howareyou == "fine": print("godo ;0") elif howareyou == "Bad": print("Sorry to hear that" ,forename, " :(") baday(str) elif howareyou == "bad": print("sorry ttpo hearthat" ,forename, ";9") baday(str) else: print("Not a valid option" ,forename, " :)") #if there is an incorrect input this triggers, restarting the 'how areyou' function hru(str) hru(str)

28th Jun 2021, 12:26 PM
Findlay Wright
Findlay Wright - avatar
2 Answers
+ 1
If EOFError is caught before the forename is entered, that would explain why forename is not defined. If you're running in Sololearn's Code Playground remember to specify all inputs in the dialog that shows after hitting Run. For example, John Smith good When I run it, I get an error that "ocul" is not defined. I don't get the error you mentioned unless I leave the inputs blank.
28th Jun 2021, 12:40 PM
Josh Greig
Josh Greig - avatar
0
What are the inputs that give the error ? I got an error but nothing like that
28th Jun 2021, 12:34 PM
Abhay
Abhay - avatar