Oct-12-2021, 09:01 AM
(This post was last modified: Oct-12-2021, 12:23 PM by Yoriz.
Edit Reason: Added code tags
)
Hello,
So I was trying out a hangman game from this website and I have an issue that I can't seem to solve in other projects as well.
There is no error or anything, the loop just breaks off I guess.
I played around with the code but I can't find the solution. I have had this problem before because of the same reason. If answer is yes, nothing happens.
Thank you for your help
So I was trying out a hangman game from this website and I have an issue that I can't seem to solve in other projects as well.
def play_loop(): global play_game play_game = input("Do You want to play again? y = yes, n = no \n") while play_game not in ["y", "n","Y","N"]: play_game = input("Do You want to play again? y = yes, n = no \n") if play_game == "y": main() elif play_game == "n": print("Thanks For Playing! We expect you back again!") exit()In the part here, when the game is over, it asks you if you want to play again, if you answer yes the program is over, if you say no the program exits (as it should) and if you answer with something else, it asks you again until you answer with either yes or no, though when you answer with yes, the program stops again.
There is no error or anything, the loop just breaks off I guess.
I played around with the code but I can't find the solution. I have had this problem before because of the same reason. If answer is yes, nothing happens.
Thank you for your help