Discuss / Python / 练习

练习

Topic source
def trim(s):    while s != '' and (s[0] == ' ' or s[-1] == ' '):        if s[0] == ' ':            s = s[1:]        elif s[-1] == ' ':            s = s[:-1]    return s

  • 1

Reply