Discuss / Python / 练习

练习

Topic source

def trim(s):

  if s[:1]==' ':

    return s[1:len(s)]

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

    return s[:len(s)-1]

  else:

    return s

a=trim(' Hello World! ')

print(a)


  • 1

Reply