python keep value recursive function

Solutions on MaxInterview for python keep value recursive function by the best coders in the world

showing results for - "python keep value recursive function"
Hana
28 Jan 2017
1def to_string(node):
2    def actual_recursive(node):
3        nonlocal a_str		# ~global, can modify surrounding function's scope.
4        a_str += str(node.val)
5        if node.next != None:
6            actual_recursive(node.next)
7    a_str = ''
8    actual_recursive(node)
9    return a_str