Blog

Reverse String using Recursion in Python

def rev ( s ) :

if ( s == s[0] ) :

return s[0]

else :

n = s[-1] + rev ( s[ : -1 ] )

return n

 

st = input ( ” Enter String : “)

r = rev ( st )

print ( ” Reverse of String is : “,r )

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!