I need help with my reverse and to_plain_list functions. I'm not sure I understand how to make them recursive and then not exceed maximum recursion depth.
def reverse(self, current=None, previous=None):
"""Reverses the order of nodes in the linked list."""
if current is None:
current = self._head
if current is not None:
next_node = current.next
current.next = previous
self._head = self.reverse(next_node, current)
def to_plain_list(self, current=None):
"""Returns a regular list with the same values as the linked list."""
if current is None:
current = self._head
if current is None:
return []
else:
return [current.data] + self.to_plain_list(current.next)