Discuss / Python / none

皇甫Yuri

#1 Created at ... [Delete] [Delete and Lock User]
def trim(s):
    if not isinstance(s, str):
        raise TypeError('bad string type:',s)
    elif s[0] == ' ':
        return trim(s[1:])
    elif s[-1] == ' ':
        return trim(s[:-1])
    else:
        return s

  • 1

Reply