'''
def reverse(s):
s= list(s)
l , r=0, len(s)-1
while l<r:
s[l],s[r] = s[r], s[l]
l=l+1
r=r-1
return "".join(s)
'''
'''
def reverse(s):
return s[::-1]
'''
'''
def reverse(s):
result =''
for char in s:
result = char + result
return result
'''
'''
def reverse(s):
return ''.join(reversed(s))
'''
input_string="Narendra"
print(reverse(input_string))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter