A utility function to insert a new node at the beginning of doubly linked list
def insert ( head , data ) : NEW_LINE INDENT temp = Node ( data ) NEW_LINE if not head : NEW_LINE INDENT head = temp NEW_LINE DEDENT else : NEW_LINE INDENT temp . next = head NEW_LINE head . prev = temp NEW_LINE head = temp NEW_LINE DEDENT return head NEW_LINE DEDENT