Discuss / Python / 练习

练习

Topic source

😶

#1 Created at ... [Delete] [Delete and Lock User]
def trim(s):    x = 0    c = -1    for i in s:        if s[x] == " ":            x += 1        else:            break    for i in s:        if s[c] == " ":            c += -1        else:            break    if c == -1:        n = s[x:]    elif c != -1:        n = s[x:c + 1]    print(x,c,n)    return n

  • 1

Reply