Discuss / Python / 作业

作业

Topic source

def trim(s): if len(s)==0: return '' else: while s[:1]==' ': s=s[1:] while s[-1:]==' ': s=s[:-1] return s

magicla_icy

#2 Created at ... [Delete] [Delete and Lock User]

再改良~

def trim(s): if s!='': while s[:1]==' ': s=s[1:] while s[-1:]==' ': s=s[:-1] return s


  • 1

Reply