about summary refs log tree commit diff
path: root/users/wpcarro/scratch/facebook/delete-node.py
blob: 4034449ef0cdaeb0e81e7410f49bc87cbfb77c21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from linked_list import Node, from_list

def delete(node):
    if not node.next:
        node.value = None
    else:
        node.value = node.next.value
        node.next = node.next.next

one = Node(1)
two = Node(2)
three = Node(3)

one.next = two
two.next = three

print(one)
delete(two)
print(one)