From 313b64903cd91194add444e7c7607dee24f798e3 Mon Sep 17 00:00:00 2001 From: Conor Walker <39270500+conor-walker@users.noreply.github.com> Date: Wed, 26 Jan 2022 11:56:21 +0000 Subject: [PATCH 1/2] makes exiting better --- src/pydle.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pydle.py b/src/pydle.py index 5c282ed..c8191ab 100644 --- a/src/pydle.py +++ b/src/pydle.py @@ -32,6 +32,9 @@ def checkRight(wordToGuess, guessSoFar): else: return False +def quit(): + input("Thanks for playing! Press ENTER to exit :)") + sys.exit(0) def header(): return r" ______ ______ _ _____" + "\n" + \ @@ -66,12 +69,11 @@ while counter < 6: wrongLetters.add(userGuess[i]) if checkRight(wordToGuess, emptyWordGuess): print("Congratulations! The word was", ''.join(wordToGuess).capitalize()) - exit(420) + quit() print("Incorrect letters: " + ', '.join(wrongLetters)) - print("Correct letters in the wrong place: " + ', '.join(rightLettersWrongPlace)) print("Result: " + " ".join(emptyWordGuess)) counter += 1 print("Ran out of guesses! The word was: ", "".join(wordToGuess)) -exit(69) +quit() From 719c89287cc1886fb9c4d979701d0d5e12d87f07 Mon Sep 17 00:00:00 2001 From: Conor Walker <39270500+conor-walker@users.noreply.github.com> Date: Wed, 26 Jan 2022 12:14:38 +0000 Subject: [PATCH 2/2] Update pydle.py --- src/pydle.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pydle.py b/src/pydle.py index c8191ab..10c7baf 100644 --- a/src/pydle.py +++ b/src/pydle.py @@ -32,10 +32,12 @@ def checkRight(wordToGuess, guessSoFar): else: return False + def quit(): input("Thanks for playing! Press ENTER to exit :)") sys.exit(0) + def header(): return r" ______ ______ _ _____" + "\n" + \ r"| _ \ \ / / _ \| | | ____|" + "\n" + \ @@ -48,8 +50,7 @@ print("Welcome to...") print(header()) print("A totally original guessing game!") emptyWordGuess = ["_"] * 5 -wrongLetters = set() -rightLettersWrongPlace = set() +wrongLetters, rightLettersWrongPlace = set() wordToGuess = list(getWord().upper()) # print(wordToGuess)