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无用
悬赏问题
- ¥15 目详情-五一模拟赛详情页
- ¥15 有了解d3和topogram.js库的吗?有偿请教
- ¥100 任意维数的K均值聚类
- ¥15 stamps做sbas-insar,时序沉降图怎么画
- ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
- ¥15 关于#Java#的问题,如何解决?
- ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
- ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
- ¥15 cmd cl 0x000007b
- ¥20 BAPI_PR_CHANGE how to add account assignment information for service line