Recursive String Reversal

Mon 10 August 2026
def reverse_string(text):
    if len(text) == 0:
        return text
    return reverse_string(text[1:]) + text[0]

print(reverse_string("Python"))  # Output: nohtyP
nohtyP


Score: 10

Category: chapter8_recursion