Discuss / Python / day3
def trim(s):
    if s == ' ' or s is None:
        return ''
    start = 0
    end = len(s)
    while s[start:start+1] == ' ':
        start = start+1
    while s[end-1:end] == ' ':
        end = end-1
    return s[start:end]


def trim(s):

    if s == ' ' or s is None:

        return ''

    start = 0

    end = len(s)

    while s[start:start+1] == ' ':

        start = start+1

    while s[end-1:end] == ' ':

        end = end-1

    return s[start:end]


  • 1

Reply