Beginner programmer here, using Python 2.7.10. I've got this code:
def yesno():
answer = raw_input("(Y/N) > ").upper()
if answer == "Y":
return True
elif answer == "N":
return False
else:
yesno()
if yesno():
print("Yes")
else:
print("No")
I'm trying to call the function within itself to 'restart' it if the conditions aren't met. The problem I have is that when I restart it more than once it will not return the value it should. For example, if I input "X" the first time but "Y" the second time, it will still print "No" in the end. Is there a better way to restart a function within itself?
return yesno()
instead ofyesno()