From 5d40aaa36353603ab4527ed712b3f7c8d8a7fd92 Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Thu, 10 Sep 2020 09:50:59 +0000 Subject: [PATCH] Added if __name__ == "__main__": check. --- hangfish.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hangfish.py b/hangfish.py index cf8ef74..7a3b2e7 100644 --- a/hangfish.py +++ b/hangfish.py @@ -48,15 +48,19 @@ class HangFish(): def getString(self): return self.graphical_string + 'guesses left = {}\n'.format(self.guesses) + self.graphical_progress_string -hangFish = HangFish(None, "Gen") +def main(): + hangFish = HangFish(None, "Gen") -print(hangFish.getString()) -while (hangFish.running): - try: - letter = str(input("Enter Letter\n"))[0] - hangFish.guess(letter) - print(hangFish.getString()) - except IndexError: - print("Please enter a letter.") + print(hangFish.getString()) + while (hangFish.running): + try: + letter = str(input("Enter Letter\n"))[0] + hangFish.guess(letter) + print(hangFish.getString()) + except IndexError: + print("Please enter a letter.") -print (hangFish.status_message) + print (hangFish.status_message) + +if __name__ == "__main__": + main()