I have created subroutines for a Hangman / Guess the word game. I want to ask the user if they want to start a new game after finishing the previous one. I’m stuck between line 35 - 55.
Will anyone please share their expertise how I can better write my code or at least, teach me how to insert the while loop (category) inside my subroutine - def Again():
Thanks a ton in advance!
Line 35
if allLetters:
print(f"You've won with {lives} left. Well done!")
break #should ask user to go again
if lives <=0:
print(f"You ran out of lives! The answer is {word}")
break #should ask user to go again
else:
print(f"{lives} lives left")
def Again():
playAgain=input("Do you want to play again? y/n: ").lower()
if playAgain=="n":
print("Hope you enjoyed the game!")
print("Logging out...")
time.sleep(2)
os.system("clear")
exit()
else:
os.system("clear")
Line 55 #needs to add a loop below which leads the user to the while loop below (category)