 Okay, welcome back to our from scratch to Python series. In this video, we're going to build upon what we've done in previous tutorials where we've located the column position inside a line of text here. In this tutorial, we're going to use that position to split up a line into its word and to its sentence value. Now I'm the surfing scratcher, and I'm here to help curious learners just like you along on your learning journey. So let's get stuck into it in just a sec. So we're going to do something similar in creating a custom block. That's going to be our goal. It's going to be to slice a line into a word and a sentence. So we're going to make it sort of slightly templaty or a little bit generic so we can do that. First thing I'm going to do is create a new variable. I'm going to put an underscore again because it's going to be a helper variable because I'm going to reuse it multiple times. And I'm going to call it text output. And this is just going to store a text value that we're going to use later down the track. So text output, you can see it there on the screen. And just like in our other custom block over there, we're going to set the value of text output to nothing actually because this is going to be a text value. So we don't want anything to be in there at the moment. The next thing that we're going to do is we're going to use that helper variable, that index counter again, because we are going to be counting the position inside of a line here. So we're going to set i to the starting index. And our starting index will always be one. And we're going to change this in our custom block down the track, but we're just going to hard code it in now to test it. Okay, we're going to grab a another repeat until block. And let's go over to the operators and grab an equal to operator. And we're going to repeat until this value of i is equal to our end index. And we need to specify what that end index is. So let's just hard code in there for the moment. So if we're thinking about this first line, it's one, two, three, four, five. We want the end index to be five here. Okay, so we're going to start at one, which is where the D is. And we're going to repeat it until i is equal to that fifth value. The next thing that we will need to do is we need to change that value of i. So let's just increment it like we did in the other one. Okay, and this is where this block is going to get a little bit gnarly. So what we want to go ahead and do is capture each character or letter that we're iterating through up until the end index. And we're going to capture that value in the text output. The way that we can do that is using this join block here. Hey, it's serving scratcher from the future. What the join block does here is it just combines two text values together. So it will join apple and banana to form one string here. And there's actually a little space after apple there too. So that's what the join block does. We can get the current value of the text output. Remember, it's equal to nothing when we start this. And then we can get the letter value of the line that we're interested in here. So just to hard code it in, let's copy this line that we've got there. And let's go across and just duplicate this letter block that we've got here of line. And what we're going to do is just take out this line parameter here and dump it. And we're just going to put our sentence in there to hard code it. So we're going to join the current value of the text output with the current letter of what we're iterating through, what we're looping through here. Now the best way to see this is to take that code block and put it in a set block. So let's set the text output to this value that we have just created here. And then we're going to go in and plonk that above the change block because we set i2 to 1 here. And if you want to see what's going on, I recommend that we put a weight block in here as well. So I'm just going to put the weight block after it all and let's just go to 0.5. Now I'm struggling encourage you to go through this code block to just talk it out. Again, act it out with someone else. Like if you're there with a friend or with a family member or brother or sister or sibling, go through and assign one of you to text output and assign one of you to i. And then you can keep track of what both of these values will be. So let's repeat until i is equal to 5 or i is currently equal to 1. So let's set the text output to the current value of text output, which at the moment is nothing. Okay, the current value of it is nothing. And I can just get it up here just currently equal to nothing there. Then when we get inside of here, we're going to join its current value and the letter of i or the letter of i is one at the moment. So we're going to join the nothing to D. Okay, then we're going to change the value of i by 1. So i will now be equal to 2. And we're going to wait. Come back to the start. We're going to join the current text output, which is now D, remember, because we just set it to D previously. And then we're going to get the second letter in here, which is a. So we're going to go D, join it to that letter a. Cool. Then we're going to change i by 1. So i is now equal to 3. And we keep doing this until i is equal to 5. All right, let's click this code block and let's check out the values of i here and text output and watch text output build out. Here we go. D, A, S, H. Fantastic. So we stopped before we included the colon there, which is great. So you can see here that we've just extracted out the word of our line here. So that's all well and good for the word, but now we want the sentence, right? So I'm just going to again show you how to do this by hard coding it, and then we're going to make this pretty and make it into a custom block. So we would change the starting index from one to the value that is after the colon here. So I think if it is five, then we want it to be either six or seven. So I'm entirely sure what it is at the moment. So let's just make it seven. It could be six. So I'm just trying to account for the space there. And we want to repeat until i is equal to the end of this text. Well, there's a nice little value reporter block that we could use for that. So we get the length of the value and let's just again copy and paste that line. So we can get the length of that, which is 48. So we're going to repeat until the length of this line. And now hopefully when I click this, we should get the value of the text output to be the sentence. So let's just click it and see. There we go. And it's starting to build out very slowly using our weight block time here of 0.5. You can see i is incrementing. We're getting the character, the letter value of each of those characters. And we are creating this sentence. So should she try and make a dash for the car? And this might even go off the screen. But there we go. We made it. And we're at the end, which is 48. So what we've just seen is that we can use this same co block to extract a word and the sentence. Okay. And all we need to do was change the start value and the end value of that index. So with that in mind, we can insert the value of that column position because the column position is basically the endpoint for the word. And it's sort of the start point for the sentence. So that is the delimiter. Like it is the sort of separator between these two things. So now let's go ahead and create a custom block to make this a bit more of a template so that we can use it for both words and sentences. And we can get rid of all the stuff here that we've hard coded in. So I'm going to create a new block and we're slicing up the pieces of text here. So I'm going to call it a slice and I'm being sneaky because I know this is some Python language as well, but we're kind of chopping up the text here. So we're going to slice up a, let's call it a line. Remember we're slicing up the line and I'm going to add a label here just so we can create some more description of what we're actually doing. So we're going to slice a line from, we're going to slice it from the start index and add another label here and we're going to slice it to the end index here. So when we read this from left to right, we're going to slice a line of text from its start index to its end index. Okay, I'm going to click or okay there, not all right. And there we go. We've got our custom block here. We can connect it all up and it's nearly ready to go for us. So the first thing that we can do is wherever we've got this line business going on, we can put in that line there. So we're now going to put in line in those two spots. We now need to create the templates for the start index and the end index. Well, the start index is just going to be what I is, right? And the end index, well, that's what we're repeating up until. So we don't actually need that length of line. I'm just going to pop it up there for the moment and we're going to repeat until the end index. All right. Now, if you want to test this out, let's just grab this slice block, this new slice custom block. I'm going to grab that line of text, slice this text. We're going to slice it to from the first index and we'll slice it up until the length of the colon here. And I'll click this and you can see we've just got Bath. I'm actually just going to get rid of that weight block now. So if I click it, you can see we've got Bath here in text output. Now, the cool thing is, if we connect these two blocks together, we're going to set the colon position here of this line of text, which is Bath, take a nice little Bath. And we now have a value of the colon position here. So we can now say that, okay, let's slice it to get a word, we can slice it from the start of a line up until the colon position because we know what the colon position is. And if you're not sure what that is, check out the last video tutorial up in the top right hand corner that will walk you through that. But that's why we create custom blocks because we know that that's what this line does. It sets the colon position of this line. So if I click this, we should still get the same result of Bath and we do. Now, if I just duplicate this and you want to test out the sentence now, well, that's where we can get the colon position. Okay, we can get the colon position, we want to start from the colon position. And now what you want is you want to go to the length of this text here. So I've just got a hard code that value in for the moment, but we'll stick that in there. And if I click this, we should get the text output. I think it's going to be off for a little bit because we just need to increment colon position. There you go. So take a nice one Bath and relax for a while. So you see we've got the colon and the space there. So what we would need to do is our start index would actually need to be the colon position, I think plus two, and we might even need to change this down the track as well. But let's just click this again. And there you go. We've just truncated off the colon and the space to take a nice warm bath and relax for a while. And that's actually not a bad place to park this tutorial. I might go and run the bath and relax for a while and catch you in the next one. The next tutorial, we're going to use these code blocks to create more custom blocks. And we're also going to step through each of these lines so that we can extract out all the words and the sentences and put them into lists. So that's what you've got to look forward to. And I look forward to catching you in that one.