 Alright, welcome back everyone. This is Christian. So in this final video on lesson, we're going to do two very simple implementations. We're going to update an existing item or pet and list here. And also we're going to return or search for a pet using the index position. Okay, so it's quite simple. We have a lot of the other operations already in place so we can easily do that. Let's do the update first. I think that's pretty simple. So let's go over here and implement our code over here. I'm going to do a function called replace and replace the current key with the new key item. Okay, so we're not actually creating any, any new, you know, node which is basically it plays a content. So that's all I'm going to do. So first is we're going to search the list, right? We search it and then we're going to return the node from the search result. But before that is the base case. So if the self.head is none, then return nothing. Otherwise, we're going to do a current node is equal to self.search. We have the search key already. Okay, so it's going to go out there and do a search. It comes back. We can check that the current node is not null. I mean, we found the key. Then basically just to occur node item is equal to the new item and then that's it, right? Pretty simple because we have our operations already in place. So let's see if this works. Let's go over here. Okay, so we have our list already empty. If I run it again, right? So let's, let's remove some of these functions so we don't want to remove them. So I know this already working. So I'm going to delete them. You know, all of these guys up to here. Okay, it's going to comment this out. And right below here, we're going to just replace. Let's say let's put this again. Let's see what it looks like first. We've got a pretty long list right here. Okay, so if for this year, let's replace the cat again. Sorry, Katie, with another, another pet. So let's copy this for now. And we're right here. And we'll just say replace. And we're going to replace the cat. So the cat, I'm going to copy the cat here. And we're going to replace it with a different path. Let's go back to a emoji site. And let's choose a ladybug this time. So right in here, replace a cat with a ladybug. And then we're going to do a print and we'll see if that's correct. It's clear the list here and run. It didn't happen. No, it didn't happen. It didn't happen right. Okay, let's see. Did we do it incorrectly? The key is the cat. And we're going to return the cat. And the, oh, it's not currently none. Supposedly none. Right, one more time. Let's try again. Here we go. Here we go. We replace the cat with the ladybug. So we're good to go. Right. So that's pretty simple. Now the next thing is we're going to choose an item on this list. So let's say that again, I'm going to turn all these off. We're going to save a lot of these pets up here. I'm going to do right after let's say, okay, this is pretty long, pretty good list. Right. So this is the pet one, two, three, four, five, six of them, right. So the index of that. I don't know if our size is correct. I think there's some errors. And I would check. So I doubt it. I think there's a few bugs in there. But let's see. Pets. It's that size. And we'll put around that we'll see you happen sizes for a second. Yeah, it's not right. So again, this is something that you may or may not choose to do. I probably missed by two. So maybe the insertion part is not right. And you can also check to make sure that when all these are on, right. That means at the very bottom, I should have a size of zero right down here. Okay. And if you check that you see that I have a minus three. Yeah, so you can see that it's not correct. This should be one right. So that when I delete it's not update when I add my new ones, you can see when I move, we move the head and tail. It's not correct. Right. So that means something in the code so over here you can kind of look at this. Yeah, that's why when you add new nodes. So we only update when we see a pen looks good. Yeah, that's a prepend. Same thing here at the end. We don't do here. Did search nothing answer after. Okay, we saw after here. Yeah, so we did not update here. So after we added the new note you're right here we need to put here. Self that size plus one. That's the one to return actually. Okay, so that one there. And so before we got it here looks good. We move head reduction here. We move tail we do the same thing here looks good remove item. Okay, item. We did one here. Okay, but notice that we did remove head and remove tail. So when we did that, and we subtracted again right because the remove head and tail already subtracted that so that means this one only applies to this part. Okay, not the entire if it goes here we already moved it, moved one. Otherwise, we will move one down here. So this part of the years. Okay, so let's replace it. I think so let's try again. Right so list and run. I think it's almost one off right. No, actually it's correct. Yes, because they won but later back in the end. So that is correct. If again if I turn. If I turn these off. Right besides should be one still if I turn all of these off. Okay, so you can see that we have six here. So that's correct. Okay, that's good. So now we can turn this one off. And then we can also turn these off. And let's do up here. All right, so way up here, we have a good list of pets in our data. Okay, so we have a lot of these here. Maybe I should really put that one so I can know what the size kind of hard to see how many sites we have. Size. Okay, so the size in here is going to be a size of eight. Okay, so good. So now we can have a user ask, you know, up to a pets. Okay, so we can do that by going something to something like this I would say index is equal to input. I'm going to ask my integer input enter number. Okay, between one eight for that example. And because we do index positions going to minus one right away. And then we're going to do a something like pets, this dot, and would do here. Search, maybe search by index, something like that, and passing the index to that function. Okay, so I'm going to copy this function, make sure I do it right over here. And let's go and create a function down here. Search index, and then we're going to pass the index to this function here like that. And so it's quite simple now just say if again itself head is equal to none, then return nothing. Otherwise, we're going to check the index we will make sure the index is within the boundary eight here right, let's say we don't accept negative index, you know, also will accept any index larger than eight. So this can be as minus seven right. So index number we already decremented by one. Okay, so you make sure we do it right. I mean that if the index is negative. If we don't get it, we don't allow for the index is greater than the self that size minus one right. If that's the case, then we just return. It's out of bounds. Otherwise, go ahead and do the operation so just copy this so head. And then we're going to search again. We're going to loop through that all the way to index. So if they pick like the position number four. That means it's going to be from zero, one, two and three right all the way to that and then we return that position, and then we turn the pet. So here will be doing for loop for I and the range of index. So a current node is equal to current node that next just key out from a comment at updating what advanced the current node until the end and finally down here we find it we're going to return the current node. That's it. Right. And we will see if this is correct or not. Go and take a look. And let's see around this. And here we go. I asked one number. Let's put one. I should get a lobster. And I did not get that because I didn't have printed. Perfect. So I returned that position. And I put here. He's quoted that. Okay, so we turn current. Yeah. Let's do it again for kind of do that. And one more time pen number one is the lobster. Here we go. One more time. What to the eighth position that should be the lion. And one more time for the rooster maybe as clean this up rooster is number 1234 so the rooster isn't the four and there it is. So you can see we had a lot of operations using linked list there are mainly we can do we did not do any sorting. Maybe I'll leave that as activity for you to do that sorting does tell me effort. The couple ways to do it. Remember this is not an array so you can't really do like binary sorting things like that but you can certainly sort using you know above a sword or merge sort of things like that a little bit. But there you go. I hope this is helpful and hope you enjoyed this course. If you have any questions feel free to ask and put a comment I'll be more happy to answer. Thank you and enjoy.