链接: https://pan.baidu.com/s/1dHfJoVv 密码: snty
# delete black space first and last
s = " hello jeapedu com "
i = 0
h = -1
e = -1
t = ""
while i < len(s):
if not s[i].isspace(): # find first non blank space char
h = i # mark i to h
break # if found, then break
i += 1
print(h)
i = len(s) - 1 # last char
while i > -1: # do cycle backward
if not s[i].isspace(): # find first non blank space char
e = i # mark i to e
break # if found, then break
i -= 1
print(e)
print(s[h : e + 1])