Challenge: Reverse Recursively

Lab Python Beginner 10 points

Read a line of text and print it backwards using a recursive function (no slicing with [::-1], no reversed).

Input

One line of text (at most 300 characters).

Output

The text reversed.

Example

Input

stressed

Output

desserts
Sample input available Sample output available
Editor
Python

Hints

Base case: a string of length 0 or 1 is its own reverse.

reverse(s) = reverse(s[1:]) + s[0]

Solution explanation

Each call moves the first character to the end of the reversed rest.

Show solution
def reverse(s):
    if len(s) <= 1:
        return s
    return reverse(s[1:]) + s[0]

print(reverse(input()))
Output
Answer
HOME LABS COMMUNITY DASHBOARD