Discuss / Python / 练习

练习

Topic source

Herman.

#1 Created at ... [Delete] [Delete and Lock User]
def trim(m):
    if m == ' ':
        return m    elif m[0] == ' ' and len(m) > 0:
        s1 = m[1:]
        return trim(s1)
    elif m[-1] == ' ' and len(m) > 0:
        s2 = m[:-1]
        return trim(s2)
    else:
        return mm = input('one str:')
a = trim(m)
print(a)

  • 1

Reply