Skip to content
Open
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
7 changes: 5 additions & 2 deletions hangman.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Importing all the required libraries"""
import random
from words import words
from hangman_visual import lives_visual_dict_easy, lives_visual_dict_hard, lives_visual_dict_medium, \
Expand All @@ -10,7 +11,7 @@
def get_valid_word(words, lives):
"""Gets word from words.py wihtout '-' or ' '."""
word = ""

"""Choosing words based on the difficulty level picked by user"""
if lives == 12:
word_dict = [word for word in words if len(word) >= 4 and len(word) <= 6]
word = random.choice(word_dict)
Expand Down Expand Up @@ -42,6 +43,7 @@ def hangman():
alphabet = set(string.ascii_uppercase)
used_letters = set()

"""Gives points to the user based on the difficulty level"""
if lives == 12:
visual = lives_visual_dict_easy
point = int(1)
Expand All @@ -55,6 +57,7 @@ def hangman():
visual = lives_visual_dict_impossible
point = int(15)

"""Prompting user on their current status"""
while len(word_letters) > 0 and lives > 0:

print(f"\nYou have {lives} lives left and you have used the letters:", " ".join(used_letters))
Expand Down Expand Up @@ -82,7 +85,7 @@ def hangman():
print(f"{user_letter} is not a valid input.")

# gets here when len(word_letters) == 0 or lives == 0

"""Promt for THE END"""
if lives == 0:
print(lives_visual_dict_easy[lives])
print(f"Hahaha... he died... The word was {word}")
Expand Down
3 changes: 2 additions & 1 deletion hangman_visual.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Different stages for animation based in the difficulty"""
lives_visual_dict_easy = {
0: """
___________
Expand Down Expand Up @@ -248,4 +249,4 @@
""",

3: "",
}
}
Loading