Not sure why i'm getting NameError for clinic()

def clinic():
    print ("You've just entered the clinic!")
    print ("Do you take the door on the left or the right?")
    answer = input("Type left or right and hit 'Enter'.").lower()
    if answer == "left" or answer == "l":
        print ("This is the Verbal Abuse Room, you heap of parrot droppings!")
    elif answer == "right" or answer == "r":
        print ("Of course this is the Argument Room, I've told you that already!")
        print ("You didn't pick left or right! Try again.")


Do you take the door on the left or the right?
Type left or right and hit ‘Enter’.l
Traceback (most recent call last):
File “”, line 13, in
File “”, line 4, in clinic
answer = input(“Type left or right and hit ‘Enter’.”).lower()
File “”, line 1, in
NameError: name ‘l’ is not defined


input() evaluate the user input as code. if you type l, l will be evaluated as code. Which would be a undefined variable


how would you solve this problem then?
i noticed that when i return “l”, it works.


yea, "l" is evaluated as string, but its quite a security risk, given the user can inject code! surely there must be a better function


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