Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Wrap Up the Game in Style

00:00 Wrap Up the Game in Style. One problem with the current implementation of game_over() is that it doesn’t update the table of guesses with the final guess. This happens because you moved show_guesses() before input().

00:14 You can fix this by calling show_guesses() from within game_over(). In order to call show_guesses(), though, you’ll need information about the previous guesses, so you change the signature of game_over() to include them.

00:39 You need to make the corresponding change in main(). You want to call game_over() regardless of whether your user guessed the word correctly or not. This means that you don’t need the else clause any longer, so it’s removed.

01:19 As you can see, the game now shows the final guess correctly, but the users get no feedback about whether they were able to guess the secret word correctly. To fix this, you’ll need to change game_over() once more.

01:33 Start by parsing whether the word was guessed correctly. You compare the last guess and the secret word in order to see if the user guessed the word correctly.

01:48 Move to the bottom of the file, and then alter game_over() first to accept the new argument, and then add the following lines at the end.

02:24 Test the game once more.

02:40 It looks a lot better. You’ve only used the basic features of Rich, but it’s improved the user experience a great deal. You’ve made several big changes to your code in this step.

02:51 If you need to, compare your code with the version that’s included in the course materials. The game now works quite well, as long as the user plays as you would expect. In the next part of the course, you’ll add some feedback mechanisms that can guide your users if they do something wrong.

Become a Member to join the conversation.