def ll_create_node(name, phone):
return {'name': name, 'phone': phone, 'next': None}
def ll_insert(head, name, phone):
if head is None:
return ll_create_node(name, phone)
current = head
while current:
if current ['name'] == name:
current['phone'] = phone
return head
if current ['next'] is None:
break
current = current['next']
current['next'] = ll_create_node(name, phone)
def ll_find(head, name):
if current['name'] == name:
return current['phone']
return None
def ll_delete(head, name):
if head['name'] == name:
return head['next']
while current['next']:
if current['next']['name'] == name:
current['next'] = current['next']['next']
def ll_list_all(head):
items = []
items.append((current['name'], current['phone']))
return sorted(items, key=lambda x:x[0])