如果单词的结尾类似于给定列表中的任何可能结尾,我想删除单词的结尾。我使用了以下代码:
ending = ('os','o','as','a')
def rchop(thestring):
if thestring.endswith((ending)):
return thestring[:-len((ending))]
return thestring
rchop('potatos')
结果是:“锅”。但我想要这个:'potat'
我怎样才能解决这个问题?
摇曳的蔷薇
波斯汪
相关分类