Skip to content

Commit

Permalink
Create reverse_str_recursive.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh Singhal committed Apr 11, 2019
1 parent fcbcfbe commit 595c7f0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions reverse_str_recursive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Given a string, get it reversed using recursion

def recursive_reverse(input_str):
if len(input_str) == 0:
return ''
else:
return recursive_reverse(input_str[1:]) + input_str[0]

result = recursive_reverse("aabbcc")
print(result) # ccbbaa

0 comments on commit 595c7f0

Please sign in to comment.