-
Notifications
You must be signed in to change notification settings - Fork 0
Sno Ochoa C23 Snowman Feedback #34
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,25 @@ def snowman(snowman_word): | |
| If the player wins and, | ||
| 'Sorry, you lose! The word was {snowman_word}' if the player loses | ||
| """ | ||
| pass | ||
|
|
||
| wrong_guesses_list = [] | ||
| correct_letter_guess_statuses = build_letter_status_dict(snowman_word) | ||
|
|
||
| while len(wrong_guesses_list) <= SNOWMAN_MAX_WRONG_GUESSES: | ||
| letter_typed = get_letter_from_user(correct_letter_guess_statuses, wrong_guesses_list) | ||
| if letter_typed in snowman_word: | ||
| correct_letter_guess_statuses[letter_typed] = True | ||
| print_word_progress_string(snowman_word, correct_letter_guess_statuses) | ||
|
|
||
| if is_word_guessed(snowman_word, correct_letter_guess_statuses) is True: | ||
| print("Congratulations, you win!") | ||
| return | ||
| else: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your code is missing an implementation of one of the requirements. Your snowman function should display the list of incorrect guesses. @ra-choa please respond to this comment with how you would implement this feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you Mikelle, I missed this because I only looked at the readme and forgot to refer back to the Learn page. Updated accordingly here 🫡 |
||
| wrong_guesses_list.append(letter_typed) | ||
| print_snowman_graphic(len(wrong_guesses_list)) | ||
| print(f"wrong letters: {wrong_guesses_list}") | ||
| if len(wrong_guesses_list) >= SNOWMAN_MAX_WRONG_GUESSES: | ||
| print(f"Sorry, you lose! The word was {snowman_word}") | ||
| return | ||
|
|
||
| def print_snowman_graphic(wrong_guesses_count): | ||
| """This function prints out the appropriate snowman image | ||
|
|
@@ -33,7 +50,7 @@ def print_snowman_graphic(wrong_guesses_count): | |
|
|
||
|
|
||
| def get_letter_from_user(correct_letter_guess_statuses, wrong_guesses_list): | ||
| """This function takes the snowman_word_dict and the list of characters | ||
| """This function takes the correct_letter_guess_statuses and the list of characters | ||
| that have been guessed incorrectly (wrong_guesses_list) as input. | ||
| It asks for input from the user of a single character until | ||
| a valid character is provided and then returns this character. | ||
|
|
@@ -73,7 +90,7 @@ def build_letter_status_dict(snowman_word): | |
|
|
||
| def print_word_progress_string(snowman_word, correct_letter_guess_statuses): | ||
| """ | ||
| This function takes the snowman_word and snowman_word_dict as input. | ||
| This function takes the snowman_word and correct_letter_guess_statuses as input. | ||
| It calls another function to generate a string representation of the | ||
| user's progress towards guessing snowman_word and prints this string. | ||
| """ | ||
|
|
@@ -84,7 +101,7 @@ def print_word_progress_string(snowman_word, correct_letter_guess_statuses): | |
|
|
||
| def generate_word_progress_string(snowman_word, correct_letter_guess_statuses): | ||
| """ | ||
| This function takes the snowman_word and snowman_word_dict as input. | ||
| This function takes the snowman_word and correct_letter_guess_statuses as input. | ||
| It creates and returns an output string that shows the correct letter | ||
| guess placements as well as the placements for the letters yet to be | ||
| guessed. | ||
|
|
@@ -109,7 +126,7 @@ def generate_word_progress_string(snowman_word, correct_letter_guess_statuses): | |
|
|
||
| def is_word_guessed(snowman_word, correct_letter_guess_statuses): | ||
| """ | ||
| This function takes the snowman_word and snowman_word_dict as input. | ||
| This function takes the snowman_word and correct_letter_guess_statuses as input. | ||
| It returns True if all the letters of the word have been guessed, and False otherwise. | ||
| """ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of the
returnkeyword. This allows for us to exit not only the while loop early if this condition is met but also the function as a whole.