英文句子,输出其中包含字母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的单词
发布评论