I want to use recursion to reverse a string in python so it displays the characters backwards (i.e "Hello" will become "olleh"/"o l l e h".
I wrote one that does it iteratively:
def Reverse( s ): result = "" n = 0 start = 0 while ( s[n:] != "" ): while ( s[n:] != "" and s[n] != ' ' ): n = n + 1 result = s[ start: n ] + " " + result start = n return result
But how exactly do I do this recursively? I am confused on this part, especially because I don't work with python and recursion much.
Any help would be appreciated.