Discuss / Python / 作业,不知道对不对

作业,不知道对不对

Topic source

FancyFai

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

FancyFai

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

  • 1

Reply