21 lines
506 B
Plaintext
21 lines
506 B
Plaintext
Linked List Phone Book:
|
|
|
|
def ll_insert(head, name, phone):
|
|
new_node = {'name': name, 'phone' : phone, 'next': None}
|
|
if head is None:
|
|
return new_node
|
|
if head['name'] == name:
|
|
head['phone'] = phone
|
|
return head
|
|
current = head
|
|
while current['next'] is not None:
|
|
if current['next']['name'] == name:
|
|
current['next']['phone'] = phone
|
|
return head
|
|
current = current['next']
|
|
current['next'] = new_node
|
|
return head
|
|
|
|
|
|
|