Data Structures, Algorithms, Data Engineering, Data Science, Doubly Linked List.
new_node self.tail = new_node elif index is None: self.tail.next = new_node new_node.prev = self.tail self.tail = new_node else: current = self.head count = 0 while current and count < index: count += 1 current = current.next if not current: self.tail.next = new_node new_node.prev = self.tail