Discuss / Python / 回答

回答

Topic source

新军

#1 Created at ... [Delete] [Delete and Lock User]

def trim(s):

    if len(s) == 0: return s

    if s[0] == ' ': return trim(s[1:])

    return trim(s[:-1]) if s[-1] == ' ' else s


  • 1

Reply