# -*- coding:utf-8 -*-
def trim(s):
count = 0
for n in s:
if n == ' ':
count = count + 1
else:
break
s = s[count:]
count = 0
for n in s[-1:]:
if n ==' ':
count = count + 1
s = s[:-count]
return s
print(trim('hello '))
print(trim(' hello'))
print(trim(' hello '))
print(trim(' hello world '))
笨笨熊佳丽