All right. So now that you've tackled step one,
let's continue building out our project by doing step two. Again,
we have three to-dos in the starting file.
And what we're going to try and do here is we're going to generate a list with
as many of these blanks
which is represented by an underscore string as there are letters in the chosen
word. So for example, if the chosen word was apple with five letters,
then we should be able to create a list with five items and each of them being
an underscore. So then in the next stage,
we can replace some of the items inside that list with the correct letter
if the user guesses it right. So for example,
if the word was apple and the user guessed the letter p,
then we should be able to loop through each of the letters in the word.
And for every letter that it matches,
we replace the underscore with the actual letter.
So then we end up with a list that looks like this. Finally,
you're going to print that out and we should be able to see it in the console.
In the starting file, you'll notice I've added a little bit of testing code
which is just a print statement telling us what the chosen wood is,
and this will make it easier for us to debug and figure out if our code is not
doing what we want it to do. So once you've completed all of the
to-dos in step two, then this is what you should get. In this case,
the chosen word is baboon. So if,
I guess the letter b, because I'm cheating
and also because I'm trying to test the code, and I hit enter,
then you can see that it should print out a list with one,
two, three, four, five, six,
six items in it because there's six letters in baboon,
and each of the letters which I've guessed correctly in the right
are replaced in the list in the correct position. B occurs in the first and the
third letter,
so that is what's showing up in this list and everything else is still the
underscore because they're blanks and still need to be guessed.
Have a play around with the final version of the code
and once you're ready, head back, fork
the starting project and complete the to-dos in order. Now,
if you need a hint and you get stuck,
be sure to check the course resources for a link that links to again,
a Google for Education page
and have a read through the section on the range function that we learned about
in previous lessons.
Remind yourself of how it works and then go back to your code and try to tackle
it and see if you can get it to do what it needs to. Good luck
and I'll see you on the other side,