As a newbie to Python, I'm kind of learning some of the differences between Python2 and 3. In working through the Python course, it seems that there are some things that need to be changed in the code to make it work in 3. Here's the code;
def clinic():
print "In this space goes the greeting"
print "Choose left or right"
answer = raw_input("Type left or right and hit 'Enter'.")
if answer == "LEFT" or answer == "Left" or answer == "left":
print "Here is test answer if you chose Left."
elif answer == "RIGHT" or answer == "Right" or answer == "right":
print "Here is the test answer if you chose Right!"
else:
print "You didn't make a valid choice, please try again."
clinic()
clinic()
To make this work in Python 3, the print syntax needs to be changed (add parens), but another issue that comes up is the error "NameError: global name 'raw_input' is not defined". I've seen this issue come up often in my learning. It doesn't seem to come up when I run it in Python2, but in 3 it seems to need it declared as a global. However, when I add "global raw_input" to the function, it doesn't seem to work (in other cases, it worked everytime I did it.) Can someone tell me what I'm doing wrong? Also, I've heard that declaring globals is a bad habit to get into when not necessary, so what's the best way to handle them?