Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 10 additions & 66 deletions Hangman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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:
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion hangman_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@

''',


'''
88
88
Expand Down