Tatyana Ageyeva C23 Snowman Feedback#38
Conversation
mikellewade
left a comment
There was a problem hiding this comment.
Nice work, Tatyana! If you have any questions about the comments I left please let me know!
| correct_letter_guess_statuses = build_letter_status_dict(snowman_word) | ||
| wrong_guesses_list = [] | ||
|
|
||
| while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES: |
There was a problem hiding this comment.
Nice work with this while loop! 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!
|
|
||
| user_input = get_letter_from_user(correct_letter_guess_statuses, wrong_guesses_list) | ||
|
|
||
| if user_input in correct_letter_guess_statuses: |
There was a problem hiding this comment.
Good checking to see if the user_input is a key inside of the dictionary you built with build_letter_status_dict. Though we haven't talked about it yet, there are actually advantages of searching for an element is present in a dictionary vs a list/string. If you are curious, check out the term "Time Complexity" in reference to dictionaries and lists/strings.
There was a problem hiding this comment.
Thanks for the feedback here, I've changed the search in correct_letter_guess_statuses to use the get method to take advantage of the fast search in dict.
|
|
||
| if is_word_guessed(snowman_word, correct_letter_guess_statuses): | ||
| print("Congratulations, you win!") | ||
| break |
There was a problem hiding this comment.
We could also use the return keyword here to not only exit out of the loop but out of the entire function itself.
There was a problem hiding this comment.
Hm, good idea thanks, I've made a change
| if len(wrong_guesses_list) == SNOWMAN_MAX_WRONG_GUESSES: | ||
| print (f"Sorry, you lose! The word was {snowman_word}") |
There was a problem hiding this comment.
If you make the modification of replacing break with return you could then remove the if statement and just have the print statement since if the return didn't execute then that means the user passed the the allotted number of guesses.
| print(f"The letter {user_input} is not in the word") | ||
| wrong_guesses_list.append(user_input) | ||
|
|
||
| print(f"Wrong guesses: {wrong_guesses_list}") |
There was a problem hiding this comment.
For a better user experience, how could we alter this print statement so that the [] aren't wrapped around the guesses of a player?
There was a problem hiding this comment.
Thanks, I've changed output format and used .join, please check .
|
Thank you @mikellewade for constractive and informative feedback! I've got a new knowledge. It was interesting to look out for the all posiible ways to improve and simplify code. |
No description provided.