← Back to challenges

Recursion: Reverse a String

PythonHardrecursionstringslanguage_fundamentals

Instructions

Write a function that reverses a string. Make your function recursive.

Examples

reverse("hello") ➞ "olleh"

reverse("world") ➞ "dlrow"

reverse("a") ➞ "a"

reverse("") ➞ ""

Notes

  • For non-base cases, your function must call itself at least once.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: First N Mid