输入一个字符串如果该字符串以 ery 或者 ing 后缀结尾的则删除该字符串后缀的字符串否则将原字符串输出。python
def remove_suffix(s):
if s.endswith("er.y") or s.endswith("ing"):
return s[:-4]
else:
return s
s = input("请输入一个字符串:")
result = remove_suffix(s)
print(result)
原文地址: https://www.cveoy.top/t/topic/i28N 著作权归作者所有。请勿转载和采集!