1
00:00:00,070 --> 00:00:03,969
Hey! Well done for getting to the final step of the hangman project.

2
00:00:04,450 --> 00:00:05,860
Now in step five,

3
00:00:05,890 --> 00:00:10,210
we're going to complete the project by improving the user experience of our

4
00:00:10,210 --> 00:00:14,440
game. Pretty much up until now, we've already got the game functioning,

5
00:00:14,770 --> 00:00:19,180
but we were working with just three words, right? Ardvark, baboon,

6
00:00:19,420 --> 00:00:21,610
and camel. And at some point,

7
00:00:21,610 --> 00:00:24,970
the game gets pretty tiring when you're only guessing these three words.

8
00:00:25,480 --> 00:00:25,990
And in fact,

9
00:00:25,990 --> 00:00:29,590
the words were chosen so that if you see seven characters and you know

10
00:00:29,590 --> 00:00:30,423
it's ardvark,

11
00:00:30,520 --> 00:00:35,520
six is baboon, five is camel to make it easier for you to debug the code as

12
00:00:36,040 --> 00:00:39,820
you're creating it. And very often when we're writing code, it really,

13
00:00:39,820 --> 00:00:43,060
really important to help yourself when you're creating the code.

14
00:00:43,330 --> 00:00:47,440
And only once you've got all the logic down and everything's working as expected

15
00:00:47,710 --> 00:00:50,560
then to actually add the full functionality.

16
00:00:51,370 --> 00:00:54,040
So inside this step five starting code,

17
00:00:54,310 --> 00:00:58,480
if you take a look at the files over here, you'll notice two extra files.

18
00:00:58,960 --> 00:01:02,050
One is hangman_art.py,

19
00:01:02,440 --> 00:01:07,440
and here I've moved the hangman stages and all the drawings as well as a logo in

20
00:01:09,190 --> 00:01:12,760
ASCII art. So when we actually launch our game this time,

21
00:01:13,180 --> 00:01:17,770
then we're going to get the high man logo printed out like this at the beginning

22
00:01:17,770 --> 00:01:18,603
of the game.

23
00:01:19,240 --> 00:01:22,870
Now the second file here it is hangman_words.py.

24
00:01:23,320 --> 00:01:26,710
And this word list now expands on what we had before.

25
00:01:27,070 --> 00:01:31,690
And it's now a huge list of words, sorted alphabetically

26
00:01:32,080 --> 00:01:37,080
which we're going to draw upon and replace this previous very simple word list.

27
00:01:39,520 --> 00:01:42,310
The first to-do is to update the word list

28
00:01:42,310 --> 00:01:46,540
to use the one from here instead of this one.

29
00:01:46,540 --> 00:01:51,100
So deleting this line and replacing it with that. And to do this,

30
00:01:51,100 --> 00:01:53,530
you might have to look up on previous lessons where

31
00:01:53,530 --> 00:01:58,530
we talked about how to use modules in Python and how to import different files.

32
00:01:59,590 --> 00:02:01,390
Now, if you get stuck on how to do that,

33
00:02:01,630 --> 00:02:03,640
take a look inside the course resources

34
00:02:03,760 --> 00:02:08,259
and there's hints that take you towards documentation on how to do this.

35
00:02:09,370 --> 00:02:13,090
Now, once you've tackled to-do number one, scroll all the way down to find

36
00:02:13,090 --> 00:02:17,470
to-do number two, where we're going to import the stages from hangman_art.py

37
00:02:17,560 --> 00:02:21,160
and this is the same thing using modules and import. To-do

38
00:02:21,160 --> 00:02:23,530
number three is to import the logo.

39
00:02:23,560 --> 00:02:26,440
So one, two, three are all to do with modules and import.

40
00:02:27,040 --> 00:02:29,050
And then once you get to to-do number four,

41
00:02:29,080 --> 00:02:33,310
we're basically going to improve the user experience to let the user know that

42
00:02:33,310 --> 00:02:36,400
they've entered a letter that they've already guessed before.

43
00:02:36,910 --> 00:02:40,480
And when that happens, we're going to print the letter and just let them know.

44
00:02:40,900 --> 00:02:42,100
You don't have to punish them and

45
00:02:42,320 --> 00:02:45,640
you don't have to take away a life and you don't have to restart the game.

46
00:02:45,730 --> 00:02:48,520
It's just the gentle nudge and let them know that they've really guessed that

47
00:02:48,520 --> 00:02:53,520
letter. Now on to-do number five and the final to-do, we're going to let the user

48
00:02:53,800 --> 00:02:57,610
know if the letter that they guessed is not in the chosen word.

49
00:02:58,030 --> 00:02:58,810
So in this case,

50
00:02:58,810 --> 00:03:02,560
we're going print out the letter that they guessed and let them know that it's

51
00:03:02,560 --> 00:03:03,130
not in the word,

52
00:03:03,130 --> 00:03:07,240
just a little bit of feedback to make the game a little bit easier on the user.

53
00:03:07,900 --> 00:03:09,790
So once you've done all of that,

54
00:03:10,090 --> 00:03:13,930
then you should end up with a game that's like this. So,

55
00:03:13,930 --> 00:03:16,690
because there's so many words, I think it's really,

56
00:03:16,690 --> 00:03:20,230
really important that you actually have this line of testing code to tell you

57
00:03:20,230 --> 00:03:21,580
what the solution actually is

58
00:03:21,880 --> 00:03:25,990
so you can test all parts of your game because you know what the word actually

59
00:03:25,990 --> 00:03:30,130
should be. So let's guess a letter that's not in that word.

60
00:03:30,220 --> 00:03:34,630
Let's try a, and you can see the game tells us "You guessed the letter a,

61
00:03:34,990 --> 00:03:37,150
that's not in the word. You lose a life."

62
00:03:37,570 --> 00:03:41,890
And we end up with the head already drawn in the hangman.

63
00:03:42,250 --> 00:03:46,360
So now let's guess a different letter. Let's guess a t.

64
00:03:46,990 --> 00:03:51,430
Then you can see that works as expected. But what if we try guessing T again?

65
00:03:51,760 --> 00:03:55,690
Well, then it tells us you've already guessed t and it shows us the blanks

66
00:03:55,720 --> 00:03:59,530
including the t. Now if they guess a letter

67
00:03:59,560 --> 00:04:04,240
that's actually not in the word, so say a, well, in this case,

68
00:04:04,240 --> 00:04:08,020
they're gonna lose a life because it's actually not in the word and we're going

69
00:04:08,020 --> 00:04:09,370
to take away a life.

70
00:04:10,600 --> 00:04:15,250
So have a play around with the end version of the game. And as always,

71
00:04:15,310 --> 00:04:19,120
all the links are in the course resources. And once you're ready,

72
00:04:19,209 --> 00:04:22,480
then go ahead and fork the starting file and give this a go.

