Skip to content

Qiusi Agre - C24 Crow#13

Open
mikellewade wants to merge 1 commit intoAda-C24:mainfrom
SophieQA:main
Open

Qiusi Agre - C24 Crow#13
mikellewade wants to merge 1 commit intoAda-C24:mainfrom
SophieQA:main

Conversation

@mikellewade
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Author

@mikellewade mikellewade left a comment

Choose a reason for hiding this comment

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

Nice work on completing your first project, Qiusi!

Comment thread game.py
correct_letter_guess_statuses = build_letter_status_dict(snowman_word)
wrong_guesses_list = []

print()
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.

Seems like this was just leftover from development as it has no effects on your code. Make sure that you are doing a sweep on your codebase for inconsistencies in styling and stray lines of code like this.

Suggested change
print()

Comment thread game.py
wrong_guesses_list = []

print()
print_word_progress_string(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.

I like this little touch!

Comment thread game.py
print()
print_word_progress_string(snowman_word, correct_letter_guess_statuses)

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 work with this while loop! We don't actually know how many times it will take a user to guess the word or hit the limit of wrong guesses (could keep make invalid guesses) so this the perfect choice for that situation!

Comment thread game.py
while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES:
user_input = get_letter_from_user(correct_letter_guess_statuses, wrong_guesses_list)

if user_input in correct_letter_guess_statuses:
Copy link
Copy Markdown
Author

@mikellewade mikellewade Sep 3, 2025

Choose a reason for hiding this comment

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

Note that the if user_input in correct_letter_guess_statuses is shorthand (in and not in) for:

for element in sequence: 
    if element == sought_after: 
        return True
    return False

You can use this syntax to perform the above logic over a multiple kinds of iterables/sequences in Python. Later in the curriculum we will learn that they don't all have the same performance (Big O).

Comment thread game.py
Comment on lines +34 to +38
print("You guessed a letter that's in the word!")
correct_letter_guess_statuses[user_input] = True
else:
print(f"The letter {user_input} is not in the word")
wrong_guesses_list.append(user_input)
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 common rule of thumb is to perform the an operation and then after it is successful alert the user. This is so that there are no false positives sent to the user just in case of some failure in your code after the alert is since. With the print line being placed after it can only execute upon success of the prior lines.

Suggested change
print("You guessed a letter that's in the word!")
correct_letter_guess_statuses[user_input] = True
else:
print(f"The letter {user_input} is not in the word")
wrong_guesses_list.append(user_input)
correct_letter_guess_statuses[user_input] = True
print("You guessed a letter that's in the word!")
else:
wrong_guesses_list.append(user_input)
print(f"The letter {user_input} is not in the word")

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

Love that you included this! Make it easier on players by not forcing them to try and recall their previous guesses. For a better user experience, how could we alter this print statement so that the [] aren't wrapped around the guesses of a player? Recall, you would most likely have someone playing this game that doesn't have knowledge of Python. They'd most likely be thrown off by the random (to them) [] and "".

Comment thread game.py
Comment on lines +45 to +47
if is_word_guessed(snowman_word, correct_letter_guess_statuses):
print("Congratulations, you win!")
return
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 the return keyword. This allows for us to exit not only the while loop early if this condition is met but also the function as a whole. Something to consider here is readability, imagine if we decided to structure our loop like the following:

while len(wrong_guesses_list) < SNOWMAN_MAX_WRONG_GUESSES and is_word_guessed(snowman_word, correct_letter_guess_statuses): 

Which one more readily communicates to developers that this while loop is break condition is partially dependent on if the word is guessed? Why? (Note the checks themselves would function the same, though the following code of the modified while statement would look different in some places).

@mikellewade mikellewade changed the title Quisi Agre - C24 Crow Qiusi Agre - C24 Crow Sep 3, 2025
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