def trim(s):
n=len(s)
if n<=0:
return s
while n>0:
if not (s[0]==' ') | (s[-1]==' '):
break
if s[0]==' ':
s=s[1:]
n-=1
if s[-1]==' ':
s=s[0:-1]
Sign in to make a reply
岁益寒
def trim(s):
n=len(s)
if n<=0:
return s
while n>0:
if not (s[0]==' ') | (s[-1]==' '):
break
if s[0]==' ':
s=s[1:]
n-=1
if s[-1]==' ':
s=s[0:-1]
n-=1
return s