Discuss / Python / 交作业,我用归递咋不行啊

交作业,我用归递咋不行啊

Topic source
if len(s)==0 :
    return s
elif s[0]=='' :
    return trim(s[1:])
elif s[-1]=='' :
    return trim(s[:-1])
else :
    return s

我的归递咋不行啊?

终于弄清楚了,把空格符忘了加上。

AppleK

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

我用你的方法,怎么测试是失败的呢?

这怎么行?

elif s[-1] == ' ': return trim(s[:-1])

这行代码不明白,为什么是取最后一位呢?不是应该最后第二位吗?


  • 1

Reply