CJCoding With Joseph
15free / daySign inCreate account

Reverse A String Recursively

Complete reverse_string(s: str) -> str so it returns the text reversed, by recursion and without the [::-1] slice. The base case is written: the empty string reverses to the empty string. Add the recursive case, which returns the reversed tail s[1:] followed by the first character s[0]. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of text, no prompt, which the tests read and pass to your function before printing the string it returns (an empty line reverses to an empty line).

Expected Output:

noisrucer

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
RecursionSlicing
📥 Auto-Input:
recursion\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.