Use the slicing operation to implement a trim() function to remove spaces at the beginning and end of the string
def trim(s): if s[:1] !=' ' and s[:-1] != ' ': return s elif s[:1]==' ': return trim(s[1:]) else: return trim(s[:-1]) print(trim(' test'))