Discuss / Python / trim()

trim()

Topic source

KonoNA7

#1 Created at ... [Delete] [Delete and Lock User]
def trim(s):
    if s == '':
        return s
    if s[0] == ' ':
        return trim(s[1:])
    if s[-1] == ' ':
        return trim(s[:-1])
    return s

  • 1

Reply