RosettaCodeData/Task/Doubly-linked-list-Element-.../Python/doubly-linked-list-element-...

6 lines
123 B
Python

def insert(anchor, new):
new.next = anchor.next
new.prev = anchor
anchor.next.prev = new
anchor.next = new