item with some marker that suggests that the item is no longer present the problem with this approach is the number of nodes will no longer match the number of items it would be much better to remove the item by removing the entire node in order to remove the node containing the itemwe need to modify the link in the previous node so that it refers to the node that comes after current unfortunatelythere is no way to go backward in the linked list since current refers to the node ahead of the node where we would like to make the changeit is too late to make the necessary modification the solution to this dilemma is to use two external references as we traverse down the linked list current will behave just as it did beforemarking the current location of the traverse the new referencewhich we will call previouswill always travel one node behind current that waywhen current stops at the node to be removedprevious will be referring to the proper place in the linked list for the modification the code below shows the complete remove method lines - assign initial values to the two references note that current starts out at the list head as in the other traversal examples previoushoweveris assumed to always travel one node behind current for this reasonprevious starts out with value of none since there is no node before the head (see figure the boolean variable found will again be used to control the iteration in lines - we ask whether the item stored in the current node is the item we wish to remove if sofound can be set to true if we do not find the itemprevious and current must both be moved one node ahead againthe order of these two statements is crucial previous must first be moved one node ahead to the location of current at that pointcurrent can be moved this process is often referred to as "inch-wormingas previous must catch up to current before current moves ahead figure shows the movement of previous and current as they progress down the list looking for the node containing the value def remove(selfitem)current self head previous none found false while not foundif current get_data(=itemfound true elseprevious current current current get_next( if previous =noneself head current get_next(elseprevious set_next(current get_next()once the searching step of the remove has been completedwe need to remove the node from the linked list figure shows the link that must be modified howeverthere is special case that needs to be addressed if the item to be removed happens to be the first item in the listthen current will reference the first node in the linked list this also means that previous will be none we said earlier that previous would be referring to the node whose next reference implementing an unordered listlinked lists