Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed snowman function/Natalie/C22 #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 30 additions & 1 deletion game.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,36 @@ def snowman(snowman_word):
If the player wins and,
'Sorry, you lose! The word was {snowman_word}' if the player loses
"""
pass
if not (SNOWMAN_MIN_WORD_LENGTH <= len(snowman_word) <= SNOWMAN_MAX_WORD_LENGTH):
print("Invalid word length! The word must be between 5 and 8 characters.")
return

snowman_word_dict = {letter: False for letter in snowman_word}
wrong_guesses_list = []
num_wrong_guesses = 0

while num_wrong_guesses < SNOWMAN_MAX_WRONG_GUESSES:
print_word_progress_string(snowman_word, snowman_word_dict)
print_snowman_graphic(num_wrong_guesses)

guessed_letter = get_letter_from_user(snowman_word_dict, wrong_guesses_list)

if guessed_letter in snowman_word:
snowman_word_dict[guessed_letter] = True

if all(snowman_word_dict[letter] for letter in snowman_word):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your use of the all function here! Just a reminder that we do have a function called get_word_progress() that will check this for us as well!

print_word_progress_string(snowman_word, snowman_word_dict)
print("Congratulations, you win!")
print_snowman_graphic(num_wrong_guesses)
return
else:
if guessed_letter not in wrong_guesses_list:
wrong_guesses_list.append(guessed_letter)
num_wrong_guesses += 1
else:
print("You already guessed the letter and it's not in the word!")

print(f"Sorry, you lose! The word was {snowman_word}.")

def print_snowman_graphic(num_wrong_guesses):
"""This function prints out the appropriate snowman image
Expand Down