Answers for "python keep value recursive function"

2

python keep value recursive function

def to_string(node):
    def actual_recursive(node):
        nonlocal a_str		# ~global, can modify surrounding function's scope.
        a_str += str(node.val)
        if node.next != None:
            actual_recursive(node.next)
    a_str = ''
    actual_recursive(node)
    return a_str
Posted by: Guest on May-16-2021

Code answers related to "python keep value recursive function"

Python Answers by Framework

Browse Popular Code Answers by Language