Skip to content

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

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

Creating a pull request to leave review comments for Snowman#24
yangashley wants to merge 1 commit intoAda-C23:mainfrom
NataliaRaz: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!

Comment thread game.py

print_snowman_graphic(len(wrong_guesses_list))
print_word_progress_string(snowman_word, correct_letter_guess_statuses)
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?

Comment thread game.py
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 4, 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 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)

Comment thread game.py
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:
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.

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)

Comment thread game.py
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):
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 the length of wrong_guesses_list to keep track of the number of incorrect guesses the user has made in the game.

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