-
Notifications
You must be signed in to change notification settings - Fork 0
Malik Elmessiry C23 Snowman Feedback #29
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 |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| import random | ||
| from wonderwords import RandomWord | ||
|
|
||
| SNOWMAN_MIN_WORD_LENGTH = 5 | ||
| SNOWMAN_MAX_WORD_LENGTH = 8 | ||
| SNOWMAN_MAX_WRONG_GUESSES = 7 | ||
|
|
@@ -20,7 +23,30 @@ def snowman(snowman_word): | |
| If the player wins and, | ||
| 'Sorry, you lose! The word was {snowman_word}' if the player loses | ||
| """ | ||
| pass | ||
|
|
||
| correct_letter_guess_statuses = build_letter_status_dict(snowman_word) | ||
| wrong_guesses_list = [] | ||
| wrong_guesses_count = 0 | ||
|
|
||
| while wrong_guesses_count < SNOWMAN_MAX_WRONG_GUESSES: | ||
| print_word_progress_string(snowman_word, correct_letter_guess_statuses) | ||
|
|
||
| if is_word_guessed(snowman_word, correct_letter_guess_statuses): | ||
| print("Congratulations, you win!") | ||
| return | ||
|
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. Nice use of the |
||
|
|
||
| guess = get_letter_from_user(correct_letter_guess_statuses, wrong_guesses_list) | ||
|
|
||
| if guess in snowman_word: | ||
|
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. Another way that this could be done is by checking the dictionary that was constructed with |
||
| correct_letter_guess_statuses[guess] = True | ||
| else: | ||
| wrong_guesses_list.append(guess) | ||
| wrong_guesses_count += 1 | ||
|
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. Do we necessarily need to keep count of the wrong guesses? How could we get this same information from the list of wrong guesses that we have? |
||
| print_snowman_graphic(wrong_guesses_count) | ||
| print(f"Wrong guesses so far: {wrong_guesses_list}") | ||
|
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. For a better user experience, how could we alter this print statement so that the |
||
|
|
||
|
|
||
| print(f"Sorry, you lose! The word was {snowman_word}.") | ||
|
|
||
|
|
||
| def print_snowman_graphic(wrong_guesses_count): | ||
|
|
@@ -116,4 +142,5 @@ def is_word_guessed(snowman_word, correct_letter_guess_statuses): | |
| for letter in snowman_word: | ||
| if not correct_letter_guess_statuses[letter]: | ||
| return False | ||
| return True | ||
| return True | ||
|
|
||
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 work with this
whileloop! We don't actually know how many times it will take a user to guess the word or hit the limit of wrong guesses (could keep make invalid guesses) so this the perfect choice for that situation!