def test_node_can_have_next_element(self): n1 = Node(1) n2 = Node(2) n1.next = n2 self.assertIs(n1.next, n2)
def insert_after(self, key, data): prev_node = self.find_key(key) if prev_node: new_node = Node(data) new_node.next = prev_node.next prev_node.next = new_node
def prepend(self, data=None): new_node = Node(data) new_node.next = self.head self.head = new_node
def test_node_have_next_element(self): n1 = Node(12) n2 = Node(55) n1.next = n2 self.assertTrue(n1.next)