Discuss / Python / 交作业:可以去掉空格,但是多了逗号

交作业:可以去掉空格,但是多了逗号

Topic source

ny12348

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

def trim(s): r=[] n=0 while n<len(s): if s[n]==' ': pass else: r.append(s[n]) n=n+1 return r

trim(' hello ') #可以去掉空格,但是多了逗号


  • 1

Reply