def remove_dupes(head: ListNode) -> ListNode: if head: node = ListNode(head.val) head = head.next else: return ListNode("") new_head = node while head: if head.val != node.val: node.next = ListNode(head.val) node = node.next head = head.next return new_head
def del_node(node: ListNode): while node.next.next: node.val = node.next.val node = node.next node.val = node.next.val node.next = None