I am working on a project that at one point will ask the user a yes/no question. I currently use this code to handle such questions:
def yn():
global finalchoice
choice=str(raw_input("Y/N: "))
if choice == "Y":
finalchoice="true"
elif choice == "y":
finalchoice="true"
elif choice == "N":
finalchoice="false"
elif choice == "n":
finalchoice="false"
else:
yn()
pass
but this seems to be quite inefficient, specifically where I have to check for both "Y" and "y" or "N" and "n" separately. I've tried:
if choice == "Y" or "y":
finalchoice="true"
Unfortunately, all this does is ignore the 'else' command and will pass whatever I give it.
Any tips?