Created
March 13, 2013 13:02
-
-
Save wwgist/5151850 to your computer and use it in GitHub Desktop.
PYTHON: recursive pattern
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 reverseString(aStr): | |
# base case: | |
if len(aStr) == 0: | |
return '' | |
# recursive case: | |
else: | |
return aStr[-1:] + reverseString(aStr[:-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment