Skip to content

Commit 116d64a

Browse files
Refator method signature
1 parent f5b06bb commit 116d64a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

linked_list/linked_list.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def push(self, new_element: Element) -> None:
2525
current_element = current_element.next
2626
current_element.next = new_element
2727

28-
def get_position(self, position: int) -> Element:
28+
def get_element_at(self, position: int) -> Element:
2929
if position == 0:
3030
return self.head
3131
current_position, current_element = 0, self.head
@@ -50,7 +50,7 @@ def insert(self, new_element: Element, position: int) -> None:
5050
if previous_element:
5151
previous_element.next = new_element
5252

53-
def show(self):
53+
def show(self) -> None:
5454
current_element = self.head
5555
elements = []
5656
while current_element.next:
@@ -70,16 +70,16 @@ def show(self):
7070
linked_list.push(third_element)
7171

7272
assert linked_list.head is first_element
73-
assert linked_list.get_position(0) is first_element
74-
assert linked_list.get_position(1) is second_element
75-
assert linked_list.get_position(2) is third_element
73+
assert linked_list.get_element_at(0) is first_element
74+
assert linked_list.get_element_at(1) is second_element
75+
assert linked_list.get_element_at(2) is third_element
7676

7777
fourth_element = Element(4)
7878
linked_list.insert(fourth_element, 1)
79-
assert linked_list.get_position(1) is fourth_element
79+
assert linked_list.get_element_at(1) is fourth_element
8080

8181
fifth_element = Element(5)
8282
linked_list.insert(fifth_element, 2)
83-
assert linked_list.get_position(2) is fifth_element
83+
assert linked_list.get_element_at(2) is fifth_element
8484

8585
linked_list.show()

0 commit comments

Comments
 (0)