diff --git a/Guess the Word Game/GuesstheWordGame.py b/Guess the Word Game/GuesstheWordGame.py index 51764c85ac..a8b2e31509 100644 --- a/Guess the Word Game/GuesstheWordGame.py +++ b/Guess the Word Game/GuesstheWordGame.py @@ -1,9 +1,12 @@ import random + def choose_random_word(): - words = ["apple", "banana", "cherry", "grape", "orange", "watermelon", "kiwi", "mango"] + words = ["apple", "banana", "cherry", "grape", + "orange", "watermelon", "kiwi", "mango"] return random.choice(words) + def display_word(word, guessed_letters): display = "" for letter in word: @@ -13,6 +16,7 @@ def display_word(word, guessed_letters): display += "_" return display + def guess_the_word(): print("Welcome to Guess the Word game!") secret_word = choose_random_word() @@ -49,5 +53,6 @@ def guess_the_word(): print("Game over! You ran out of attempts.") print(f"The word was: {secret_word}") + if __name__ == "__main__": guess_the_word()