(str1)
| 3 | #using recursion here to avoid recopying the string, as described in the discussion of "string buffer". |
| 4 | |
| 5 | def reverseStringRecursive(str1): |
| 6 | if str1 != "": |
| 7 | return str1[-1:] + reverseStringRecursive(str1[:-1]) |
| 8 | else: |
| 9 | return "" |
| 10 | |
| 11 | #testing |
| 12 |