Doubly linked list

It is still important to create a class that captures the data that our functions will be operating on:

    class DoublyLinkedList(object):
def __init__(self):
self.head = None
self.tail = None
self.count = 0

For the purposes of enhancing the size method, we also set the count instance variable to 0. head and tail will point to the head and tail of the list when we begin to insert nodes into the list.

We adopt a new convention where self.head points to the beginner node of the list and self.tail points to the latest node added to the list. This is contrary to the convention we used in the singly linked list. There are no fixed rules as to the naming of the head and tail node pointers.

Doubly linked lists also need to provide functions that return the size of the list, inserts into the list, and also deletes nodes from the list. We will be examining some of the code to do this. Let's commence with the append operation.