Creating a pull request to leave review comments for Snowman#23
Creating a pull request to leave review comments for Snowman#23yangashley 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(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 27 and then referencing that variable here on line 40 and also line 28.
num_wrong_guesses = len(wrong_guesses_list)
while num_wrong_guesses < SNOWMAN_MAX_WRONG_GUESSES:
# blah blah
print_snowman_graphic(num_wrong_guesses)| wrong_guesses_list = [] | ||
|
|
||
|
|
||
| while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES: |
There was a problem hiding this comment.
Nice job using a built-in method to keep track of the number of incorrect guesses a user has made!
|
|
||
| if is_word_guessed(snowman_word, correct_letter_guess_statuses): | ||
| print("Congratulations, you win!") | ||
| break |
There was a problem hiding this comment.
What's another way the logic in this loop could be written so that you can end the game without needing to use break?
| wrong_guesses_list.append(user_input) | ||
|
|
||
| print_snowman_graphic(len(wrong_guesses_list)) | ||
| 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?
No description provided.