I'm trying to program a really simple code as I'm starting in Python. The problem I have is that I'm trying to loop a while if the input has no the admitted answers. What I want from my program is that depending on a "Yes / No" answer print a line. For example if you answer in an input with Yes, print Ok. If you answer with No - Ok, you said No. And if you answer with any other answer it come back to the input again. I've tried with getting the while in a function and then placing a return after the option that isn't Yes or No (I mean any other that isn't Yes or no) but it doesn't work, it doesn't even print the thrid option (the option that tells you not to use any other word that isn't yes or no). I've been trying to solve by myself this doubt reading manuals and other posts from here, but I just can't figure out what I'm doing wrong. Thanks!
Here is my code:
def myFunction():
while True:
if answer == "yes":
print("Ok.")
break
elif answer == "no":
print("Ok, you said no.")
break
else:
print("Please, use yes or no.")
return answer