Created
July 2, 2024 16:39
-
-
Save gmotzespina/2b65a0ec7afaeba18f4767e121430c7e to your computer and use it in GitHub Desktop.
String Reversal Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reverse_string(s): | |
| if len(s) == 0: | |
| return s | |
| else: | |
| return reverse_string(s[1:]) + s[0] | |
| print(reverse_string("hello")) # Output: olleh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment