 All right, hello and welcome back. In this video, we're going to start implementing a insertion of the new node to the list. OK, actually, we're going to append to the list. So in the previous video, we created this project already. We have some of the files created. So if you haven't created yet, make sure you go back to the video to watch that first. But we did create a protocol list, one for node that contains the node class. And we have a list that will actually create the single list class as well. And our main program is called MyList. And we import the single list here. And we're going to go ahead and implement the append function. So I'm going to go over back to the drawing over here just to kind of explain this a little bit. So initially, when we're trying to program, the list is going to be empty. That means both the head and the tail nodes would be pointing to none, nothing, right? So we check that first. If that's the case, then we're going to append the node to the list. That means that both of the head and the tail will be pointing to that single node. After that, then if you have at least one node in the list, then we need to append the next node to that new list. And then we have to update the tail to point to that new node, OK? And so that's what we're going to do. All right, so let's go back to the IDE over here. And let's go right into the single link list over here. And I'm going to turn off all these files because they're confusing now, OK? So just this is already done right into inside the single link list.py. OK, so the function we're going to create is called append. This is going to append to the end of the list only. So we load this self. And we also need the item that's coming in, the new item or the new data, whatever you recall it. Now, we first want to create a new node for this. So new node is equal to no. We pass in the item to that. So we get our new node. OK, so we want to make sure the list is not empty. So you can check either the tail or the head. It doesn't matter in this case. If you do it correctly, then you both should either point to no or they're not, OK? So I want to just check the head. If the self.head is indeed equal to none, I mean the list is empty. So I'll basically point both nodes to this new node, right? So self.head is assigned to the new node and also update myself.tail pointing to this new node as well. So this is just the first time you have the single node, OK? If that's not the case, then there must be at least one node in the list. So therefore, we need to do the following. So all we think is basically, if there is one node, we don't have to worry about the head node, just a tail node, right? So all we have to do is you basically update the tail.next node, move self.tail, spell that correctly. Next node, assign that pointing instead of no or none, point that to the new node, OK? And you'll have to worry about the new node because when you create the new node, the new next node is already null or nothing. So we don't have to worry about that. In other words, you don't have to say self.next. I mean, new node.next is called null. You don't have to do that. And then we just have to assign the self.tail to this new node as well, OK? You have to do that because if you don't reset that one, that means the tail node will be the one previous to it. So it doesn't make sense, right? So you point its last node to the new node, OK? And then you update the tail to the new node. That new node becomes the new tail node. So now, if you are managing your size, you can just go ahead and make sure you update this to a plus one. So I'm going to go back out here out of the if block for your self size is plus equal one, OK? So that is the appending to the new node. And we'll test to make sure it's working. Let's go back to the main list over here. And let's add some files in here, OK? So I'm going to do a function up here. I'm going to build a list. So let's put here define a definition of build list. And we pass here the list self. I'll call it pet, OK? Pets list. Or you can call it LST, it doesn't matter. Let's make it simple. Call it LST for list. I didn't want to use list because list is a keyword, OK? So LST. And then we have the data that's coming into this list here. And then, so I'm going to pass a data of is it going to write a list of, you know, pets or animals, OK? And let's see if we can go here or put. So let's see. What should I start first? Yeah, let's start from the full loop. For every item and the data, we're going to call the list.append function. There we go. It's a pet function here. We're going to pass to this function the item, OK? So basically we're going to build the list. And then we'll, because list is a reference type. So whatever you do here to the list, it will come back and update it so you don't have to return it. So in the main program, main function, we're then going to create a new list. We'll call it pets list. It's equal to singly linked list, OK? We create a constructor. Now we have a pet list object. And we're going to build this list. And we pass to this list the pets list and also a data object. So here, I'm going to go and grab some emoji over here, OK? Some really kind of beautiful sites over here and rest of the emoji. We can use it. Give me a second here. OK. Yeah, I use this emoji website over here. If you just listen to emojis, where is it at? OK. So I already have it here. And I'm going to add this to my list right here, OK? So I have the dog and the cat in the mouse here to my list. So once I added that to the list, I can then go back and run that. And then once that's done, we need to verify it, right? So we don't have our print function yet, but we can access to make sure that that data is actually there. So we can access by going to print. We're going to print the pets list.head.item, right? Or we can get item, you could get item function. Doesn't matter. I'll make it a little bit shorter. And what would save this and give it a test and see what this one looks like, because may or may not work, I don't know, right? So let's give it a try. So we go over here and just run the program over here. And let's see what this output shows up. It's the left, right, or bottom. I don't know. We'll give it a try. Did it work? Let's try again. OK, so here I go, not the bottom, down here. You can see that it's printing this. You know what? Let me move this to the top right. So I'm going to move to the panel right. OK, so on the right side. And let's clear this again. You see that it prints the first on the list already, which is the dog. And if you want to see more, it'll be the next item, the next item. So let me just duplicate this and do it three of them. So this is the next item. This is the cat. And then this is the mouse. Next, that item. Next, OK. And so if it's correct, then we should see three of those pets being created and added here. I'm not sure why it cuts off a little bit of the right side here, but here we go. So we know it's working and it looks good. So in the next video, we're going to show how to create added list to the front. And we add a note to the front of that list.