1- from data_structures .linked_list import singly_linked_list
1+ from data_structures .linked_list . singly_linked_list import Node as SinglyNode
22
33"""
44https://en.wikipedia.org/wiki/Doubly_linked_list
@@ -189,7 +189,7 @@ def is_empty(self):
189189 """
190190 return len (self ) == 0
191191
192- def doubly_to_singly (self ) -> singly_linked_list . Node | None :
192+ def doubly_to_singly (self ) -> SinglyNode | None :
193193 """
194194 Convert this doubly linked list into a singly linked list.
195195
@@ -198,7 +198,7 @@ def doubly_to_singly(self) -> singly_linked_list.Node | None:
198198
199199 Returns
200200 -------
201- singly_linked_list.Node | None
201+ SinglyNode | None
202202 The head node of the newly created singly linked list.
203203
204204 Example
@@ -220,11 +220,11 @@ def doubly_to_singly(self) -> singly_linked_list.Node | None:
220220 return None
221221
222222 doubly_current : Node | None = self .head .next
223- new_head = singly_linked_list . Node (self .head .data )
223+ new_head = SinglyNode (self .head .data )
224224 singly_current = new_head
225225
226226 while doubly_current :
227- singly_current .next_node = singly_linked_list . Node (doubly_current .data )
227+ singly_current .next_node = SinglyNode (doubly_current .data )
228228 singly_current = singly_current .next_node
229229 doubly_current = doubly_current .next
230230
@@ -275,7 +275,7 @@ def test_doubly_linked_list() -> None:
275275 head = dll .doubly_to_singly ()
276276
277277 assert head is not None
278- s_head = head # type: singly_linked_list.Node
278+ s_head = head # type: SinglyNode
279279
280280 assert s_head .data == 1
281281
0 commit comments