def plural(word): if word.endswith(‘y‘): return word[:-1]+‘ies‘ elif word[-1] in ‘sx‘ or word[-2:] in [‘sh‘,‘ch‘]: return word+‘es‘ elif word.endwith(‘an‘): return word[-2:]+‘en‘ else: return word+‘s‘
相关文章
- 11-15Python名词单数变换为复数函数
2023-11-15 08:10:46
def plural(word): if word.endswith(‘y‘): return word[:-1]+‘ies‘ elif word[-1] in ‘sx‘ or word[-2:] in [‘sh‘,‘ch‘]: return word+‘es‘ elif word.endwith(‘an‘): return word[-2:]+‘en‘ else: return word+‘s‘