Python如何编写下列程序
给定单词为needed、raining、jumping、jumped、started,stars,请用if条件语句判断下列单词是ed结尾单词,或ing结尾单词,或其他类型。最终把三种类型的单词,分开打印(如下格式)。
ed结尾单词:
needed
jumped
started
ing结尾的单词;
rainig
jumping
其他类型的单词:
stars
Python单词尾缀的分析判断和提取
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
CSDN专家-showbo 2022-03-19 21:13关注题主要的代码如下

lst1='needed、raining、jumping、jumped、started、stars'.split('、') lsted=[] lsting=[] lstother=[] for word in lst1: if word.endswith('ed'): lsted.append(word) elif word.endswith('ing'): lsting.append(word) else: lstother.append(word) print('ed结尾单词:') print('\n'.join(lsted)) print('ing结尾单词:') print('\n'.join(lsting)) print('其他类型的单词:') print('\n'.join(lstother))
本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 3无用