python实现输入一行英文句子,输出其中包含字母e的单词

编程入门 行业动态 更新时间:2024-10-09 12:24:09

python实现输入一行<a href=https://www.elefans.com/category/jswz/34/1769696.html style=英文句子,输出其中包含字母e的单词"/>

python实现输入一行英文句子,输出其中包含字母e的单词

def extract_words_with_e(sentence):words = sentence.split()  # 将句子拆分成单词列表words_with_e = [word for word in words if 'e' in word.lower()]  # 使用列表推导式筛选包含字母'e'的单词return words_with_e# 输入一行英文句子
sentence = input("请输入一行英文句子:")# 提取包含字母'e'的单词
result = extract_words_with_e(sentence)# 输出结果
print()
print(sentence + " 句子中包含字母'e'的单词有:")
for word in result:print(word)

更多推荐

python实现输入一行英文句子,输出其中包含字母e的单词

本文发布于:2024-02-13 08:03:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1757412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:英文   句子   单词   字母   其中包含

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!