Skip to content

Snowman Feedback - Amanda Thompson#8

Open
kelsey-steven-ada wants to merge 1 commit intoAda-C24:mainfrom
tthoaman:main
Open

Snowman Feedback - Amanda Thompson#8
kelsey-steven-ada wants to merge 1 commit intoAda-C24:mainfrom
tthoaman:main

Conversation

@kelsey-steven-ada
Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada commented Sep 2, 2025

This is a "Pull Request" where folks can compare code between branches of a GitHub repo or forked repos, and leave comments about changed code. I will leave comments on this pull request with my feedback so you can see exactly what line of code my comments apply to. If you have questions about any piece of feedback, please respond here on Github or Slack me!

Copy link
Copy Markdown
Author

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Congrats on completing your first project Amanda!

For the future, I recommend practicing making more frequent, smaller commits. Especially as we have more complex projects and features, we will want those commits to help us by acting as checkpoints we can go back to if we try something out in our code that doesn't work.

Comment thread game.py
"""
pass
correct_letter_status = build_letter_status_dict(snowman_word=snowman_word)
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.

Different development teams will have different guidelines, but we typically want to describe the contents of a variable and can leave off the data type in the name. This is especially true in languages other than Python that require folks to declare a variable's type when we create it.

It would be completely valid and in some cases preferable to call this variable wrong_guesses rather than wrong_guesses_list.

Comment thread game.py
'Sorry, you lose! The word was {snowman_word}' if the player loses
"""
pass
correct_letter_status = build_letter_status_dict(snowman_word=snowman_word)
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.

Since this variable tracks the status of many letters, I recommend choosing a plural name like correct_letter_statuses.

Comment thread game.py
correct_letter_status = build_letter_status_dict(snowman_word=snowman_word)
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 use of a while loop since we don't know how many times we'll need to iterate!

Comment thread game.py
print(f"Incorrect Letters Guessed: {wrong_guesses_list}")
print_snowman_graphic(len(wrong_guesses_list))

print_word_progress_string(snowman_word, correct_letter_status)
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.

In the current flow, the user will not know how many letters are in the word they are guessing until after they have made their first guess. How could we make that a better experience for users by showing them that information before they start guessing?

Comment thread game.py
correct_letter_status[guessed_letter] = True
else:
wrong_guesses_list.append(guessed_letter)
print(f"Incorrect Letters Guessed: {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.

Nice feedback for the user so they can keep track and avoid guessing the same letters!

If we display wrong_guesses_list directly, python automatically surrounds the contents with [] and each letter with ''. This might look a little odd to a player, so consider looking into the join function provided on python strings.

Comment thread game.py
wrong_guesses_list = []

while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES:
guessed_letter = get_letter_from_user(correct_letter_status, 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.

When it comes to writing Python code, one of the guides you'll see us reference is the PEP 8 Style Guide. This is a guide for best practices when it comes to styling our code. One of the most common things we see is to try and keep individual lines of code under 79 characters including indentation. This line currently goes just past that limit. It won't cause the code to break or anything, but it is a good thing to keep in mind in terms of readability and best practices!

I see two possible fixes here:

  1. Shorter and more concise variable names:

    • While there is no hard and fast rule on how long variable names should be, we could first try shortening the variable names we use here (correct_letter_guess_statuses and wrong_guesses_list) as they are on the longer side. That being said, these names match the parameters for the function you use to call them, which is good practice, so we may want a different approach in this piece of code.
  2. Restyle the Function Call:

    • This is a great trick to have up your sleeve when making a function call that either includes multiple parameters or starts to approach that 79 character line limit! We can drop the parameters to the next line(s) to look something like the following:
    Suggested change
    guessed_letter = get_letter_from_user(correct_letter_status, wrong_guesses_list)
    user_input = get_letter_from_user(
    correct_letter_statuses,
    wrong_guesses_list
    )
    • This is known as Implicit Line Continuation in Python. Whenever we have information nested inside parentheses, brackets or curly braces, we can drop the nested information to new lines without any specific notation!

Comment thread game.py

while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES:
guessed_letter = get_letter_from_user(correct_letter_status, wrong_guesses_list)
if guessed_letter in correct_letter_status:
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.

Great use of the correct_letter_status dict to check if the user input is part of snowman_word a little more efficiently than if we tried to search the string itself!

Comment thread game.py
Comment on lines +37 to +42
if is_word_guessed(snowman_word, correct_letter_status):
print('Congratulations, you win!')
break

if len(wrong_guesses_list) == SNOWMAN_MAX_WRONG_GUESSES:
print(f"Sorry, you lose! The word was {snowman_word}")
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.

If the user has won, then we know that the if-statement outside of the loop if len(wrong_guesses_list) == SNOWMAN_MAX_WRONG_GUESSES will evaluate to False and will not be entered. When we use break to exit the loop early on a win, the loop ends, but the function continues to run and evaluate the remaining if-statement, even though we know it will not be entered.

Another option here would be to use return after the win condition which will immediately leave the function and we avoid taking time to run statements that will take no action.

Comment thread game.py
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES:
guessed_letter = get_letter_from_user(correct_letter_status, wrong_guesses_list)
if guessed_letter in correct_letter_status:
correct_letter_status[guessed_letter] = 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.

Throughout the "Practice with Python" topic, the examples show the Snowman game printing "You guessed a letter that's in the word!" after a user inputs a correct guess.

While your game does accurately show a word's progress by filling in the _ with the correctly guessed letter (like f e _ _ _ e for example), It would be nice if your game also provided feedback to the user by printing the string above like our examples do.

Comment thread game.py

if is_word_guessed(snowman_word, correct_letter_status):
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.

A return statement in Python stops the execution of code. I'm wondering if you can think of another way the logic could be written so that you can end the game without needing to use return (or a break statement) to break the loop?

This isn't a requirement, but if you'd like more practice with writing conditional logic in Python, I'd suggest thinking through and re-writing the logic so you don't need break to stop the loop.

If you choose to do so, there's no need for you to submit anything to me for re-review. This would just be for your own practice 😊

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