[1] FINISH 1-st-exercise #148

Merged
git_admin merged 23 commits from IvanBud123/2026-rff_mp:1-st-exercise into develop 2026-03-15 06:42:24 +00:00
Showing only changes of commit 050462d011 - Show all commits

View File

@ -29,7 +29,7 @@ def ll_insert(head, name, phone):
ptiny("====== TESTING ll_insert FUNC ========") print("====== TESTING ll_insert FUNC ========")
head = ll_insert(head,'Ivan','123-456') head = ll_insert(head,'Ivan','123-456')
print(head) print(head)
@ -49,4 +49,43 @@ print(head)
head = ll_insert(head, 'Boris', '111-222') head = ll_insert(head, 'Boris', '111-222')
print(head) print(head)
print("======= END TEST =======") print(f"======= END TEST =======\n\n\n")
def ll_find(head, name):
curent = head
while curent is not None:
if curent['name'] == name:
return curent['phone']
curent = curent['next']
return None
print("====== TESTING ll_find FUNC ======")
print("Ivan`s phone: "+ ll_find(head, 'Ivan'))
print("Dima`s phone: "+ ll_find(head, 'Dima'))
print("Boris phone: "+ ll_find(head, 'Boris'))
print(f"====== END TEST ======\n\n\n")
def ll_delete(head, name):
if head is None:
return None
if head['name'] == name:
return head['next']
prev = head
curent = head['next']
while curent is not None:
if curent['name'] == name:
prev['next'] = curent['next']
return head
prev = curent
curent = curent['next']
return head
print("Del of Dima:", ll_delete(head, 'Dima'))