+ 2
How to print a string in reverse using recursion on python
5 odpowiedzi
+ 5
+ 2
iTech: There is no really meaning with all this code in your case. This would be enough:
print(input()[::-1])
And it is no recursion either, as the question was about. To be recursion you have at least, from inside of the function, make a call back to an earlier instance (function value) of the function itself.
/Regards Per B
+ 1
Here's my way of doing it:
def rec(a):
if not a: return ""
return a[-1] + rec(a[:-1])
# Hope this helps