Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Rock Paper Scissor Game Replay Part Bug = Even answer No as "N" returns to start

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()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading