diff --git a/Hangman.py b/Hangman.py index 367af5d..c28ba19 100644 --- a/Hangman.py +++ b/Hangman.py @@ -2,71 +2,9 @@ import hangman_art import hangman_words - -# stages = [''' -# +---+ -# | | -# O | -# /|\ | -# / \ | -# | -# ========= -# ''', ''' -# +---+ -# | | -# O | -# /|\ | -# / | -# | -# ========= -# ''', ''' -# +---+ -# | | -# O | -# /|\ | -# | -# | -# ========= -# ''', ''' -# +---+ -# | | -# O | -# /| | -# | -# | -# =========''', ''' -# +---+ -# | | -# O | -# | | -# | -# | -# ========= -# ''', ''' -# +---+ -# | | -# O | -# | -# | -# | -# ========= -# ''', ''' -# +---+ -# | | -# | -# | -# | -# | -# ========= -# '''] - -# Create a List - # Print the logo from the hangman_art print(random.choice(hangman_art.logos)) -# word_list = ["aardvark", "baboon", "camel"] - # Randomly select word from the word_list, imported from the hangman_words chosen_word = random.choice(hangman_words.word_list) @@ -77,13 +15,15 @@ lives = 6 # Printing out the guess word -print(f"Psst, the guess word is:", {chosen_word}) +# print(f"Psst, the guess word is: {chosen_word}") + +print("This is a hangman Game. You have 7 lives to guess the chosen word \n" + "you have to guess each character in a chosen word"), "\n" # For loop for creating the dash sign for char in chosen_word: # display += "_" display.append("_") -# print(display) while True: @@ -97,25 +37,29 @@ # change the input character from Capital letter to Lowercase letter of the use input guess = guess.lower() + # Check if guess character already exist in the chosen word + if guess in display: + print(f"{guess} is already in the chosen word") + # Making a For loop to count the number of guess and make an index of that number with the missing blanks for check in range(len(chosen_word)): if guess in chosen_word[check]: display[check] = guess - stage = '' # Check if guess is not in the chosen word if guess not in chosen_word: lives -= 1 + print(f"{guess} is not on the chosen word ") # Print out the ASCII stages index base on the number of lives left as a value for the list (stages) print(hangman_art.stages[lives]) # Check for no lives and exit the loop if lives == 0: print(f"You Loose!, you now have {lives} lives left") + print(f"The chosen word is {chosen_word}") break - # print(lives) print(display) # create a counter list to use to verify the display list if no more item left diff --git a/hangman_art.py b/hangman_art.py index dbe1219..0e91cc9 100644 --- a/hangman_art.py +++ b/hangman_art.py @@ -71,7 +71,6 @@ ''', - ''' 88 88