Discuss / Python / 交作业

交作业

Topic source

关键是如何让索引不越界

def trim(s):
    while len(s) > 0 and s[0] == ' ':
        s = s[1:]
    while len(s) > 0 and s[-1] == ' ':
        s = s[:-1]
    return s

  • 1

Reply