Creating a pull request to leave review comments for Snowman#24
Creating a pull request to leave review comments for Snowman#24yangashley wants to merge 1 commit intoAda-C23:mainfrom
Conversation
yangashley
left a comment
There was a problem hiding this comment.
Really nice work on your first project here at Ada!
Please review my comments on this pull request for feedback about your submission.
Let me know if you have any questions!
|
|
||
| print_snowman_graphic(len(wrong_guesses_list)) | ||
| print_word_progress_string(snowman_word, correct_letter_guess_statuses) | ||
| print(f"Wrong guesses: {wrong_guesses_list}") |
There was a problem hiding this comment.
Currently this line prints out wrong_guesses_list as a list, like: Wrong guesses: ['s', 'd', 'q', 'g', 'h', 'x', 'w']
This works, but someone who isn't a dev or doesn't know what Python lists are might be wondering about the brackets around the letters with quotes.
How would you print out the wrong guesses not as a list, formatted like: Wrong guesses: s, d, q, g, h, x, q, w ?
How could you join together the elements in this list to print in a formatted way?
| print(f"The letter {user_input} is not in the word") | ||
| wrong_guesses_list.append(user_input) | ||
|
|
||
| print_snowman_graphic(len(wrong_guesses_list)) |
There was a problem hiding this comment.
Notice that there's some repetition in your code. len(wrong_guesses_list) appears 2 times.
When we repeat our code, it makes it difficult to maintain because we need to find all the different places the repeated code appears. For example, if I wanted to change the variable name wrong_guesses_list to wrong_guesses, I'd need to look for all the places the variable I want to change appear. You could miss one and introduce a bug. Therefore, we want to keep our code DRY (Don't Repeat Yourself).
I'd prefer a variable called num_wrong_guesses declared on line 26 and then referencing that variable here on line 36 and also line 27.
num_wrong_guesses = len(wrong_guesses_list)
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and not is_word_guessed(snowman_word, correct_letter_guess_statuses):
# blah blah
print_snowman_graphic(num_wrong_guesses)| print_word_progress_string(snowman_word, correct_letter_guess_statuses) | ||
| print(f"Wrong guesses: {wrong_guesses_list}") | ||
|
|
||
| if is_word_guessed(snowman_word, correct_letter_guess_statuses) == True: |
There was a problem hiding this comment.
Notice that the function is_word_guessed returns a boolean value, therefore is_word_guessed(snowman_word, correct_letter_guess_statuses) will evaluate to True or False.
When we have an expression that evaluates to True or False we don't need to compare that boolean value to something.
is_word_guessed(snowman_word, correct_letter_guess_statuses) == True is the equivalent of writing True == True. Therefore, we only need to write:
if is_word_guessed(snowman_word, correct_letter_guess_statuses)| correct_letter_guess_statuses = build_letter_status_dict(snowman_word) | ||
| wrong_guesses_list = [] | ||
|
|
||
| while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and not is_word_guessed(snowman_word, correct_letter_guess_statuses): |
There was a problem hiding this comment.
Nice job using the length of wrong_guesses_list to keep track of the number of incorrect guesses the user has made in the game.
No description provided.