Discuss / Python / 交作业

交作业

Topic source

# -*- coding: utf-8 -*-

def trim(s):

        if not s:

        return s

        if s[:1] ==' ':

        return trim(s[1:])

        elif s[-1:] ==' ':

        return trim(s[:-1])

        else:

        return s


  • 1

Reply