Skip to content

Creating a pull request to leave review comments for Snowman#23

Open
yangashley wants to merge 1 commit intoAda-C23:mainfrom
mikaebal:main
Open

Creating a pull request to leave review comments for Snowman#23
yangashley wants to merge 1 commit intoAda-C23:mainfrom
mikaebal:main

Conversation

@yangashley
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Author

@yangashley yangashley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown
Author

@yangashley yangashley Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants