string = 'abcdef'
def string_re1(string):
return string[::-1]
string_re1(string)
def string_re2(string):
t=list(string)
s=len(string)
for i,v in zip(range(s-1,0,-1),range(s//2)):
t[i],t[v] = t[v],t[i]
return "".join(t)
string_re2(string)
def string_revers3(string):
if len(string)<=1:
return string
return string_revers3(string[1:])+string[0]
string_revers3('sdswew')
from collections import deque
def string_reve4(string):
d=deque()
d.extendleft(string)
return "".join(d)
string_reve4('sdfs')
def string_rev5(x):
return "".join(x[i] for i in range(len(x)-1,-1,-1))
string_rev5('sdfs')