Skip to content
Merged
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
80 changes: 79 additions & 1 deletion Hangman.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
import random

stages = ['''
+---+
| |
O |
/|\ |
/ \ |
|
=========
''', '''
+---+
| |
O |
/|\ |
/ |
|
=========
''', '''
+---+
| |
O |
/|\ |
|
|
=========
''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O |
| |
|
|
=========
''', '''
+---+
| |
O |
|
|
|
=========
''', '''
+---+
| |
|
|
|
|
=========
''']

# Create a List

word_list = ["aardvark", "baboon", "camel"]
Expand All @@ -11,6 +68,9 @@
# Creating an empty list
display = []

# Create a variable to use for number of lives
lives = 6

# Printing out the guess word
print(f"Psst, the guess word is:", chosen_word)

Expand All @@ -20,6 +80,11 @@
display.append("_")
# print(display)

# for name in chosen_word:
# if guess not in name:
# lives -= 1
# print(lives)

while True:

# Print out the Guess Letter
Expand All @@ -36,15 +101,28 @@
for check in range(len(chosen_word)):
if guess in chosen_word[check]:
display[check] = guess
# Check if guess is not in the chosen word
if guess not in chosen_word:
lives -= 1
# Check for no lives and exit the loop
if lives == 0:
print(f"You Loose!, you now have {lives} lives left")
break

# for name in range(lives):
# if guess not in chosen_word:
# lives -= 1
print(lives)
print(display)

# create a counter list to use to verify the display list if no more item left
counter = []

# For loop use for looping through display list
for count in display:
if count in chosen_word:
counter += count

# comparing and validating the counter list against the display to make sure no more blank space is left
if counter == display:
print("You Won!")
break
Expand Down