I wanted to break out of the game when the replay() answer is no as "N" but typing "Y" or "N" seems like it does not make any difference.This is my first post and sorry for any mistakes. I cant post the whole code for some reason
thanks
def replay():
replay_answer = input("do you want to play again?: ")
while replay_answer != "Y" and replay_answer != "N":
input("do you want to play again?: ")
if replay_answer == "Y":
return True
if replay_answer == "N":
return False`enter code here`
break
while True:
wincheck()
replay()
>Solution :
Why did you think this would act as you wish? You do nothing with the returned result of replay()…
Try this instead for the last loop:
while True:
wincheck()
if not replay():
break
And as mentioned by @khelwood remove the first break:
def replay():
while True:
replay_answer = input("do you want to play again?: ")
if replay_answer == "Y":
return True
if replay_answer == "N":
return False