本文介绍了只打印字符串中的元音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Python 新手,我正在尝试打印字符串中的所有元音.所以如果有人输入嘿,一切都好吗?",所有元音都需要打印...但我不知道如何?(所以这不是计算元音,而是打印元音)
I am new in Python and I'm trying to print all the vowels in a string. So if someone enters "Hey there, everything alright?" , all vowels needs to be printed...but I don't know how? (so it's not about counting the vowels, its about printing the vowels)
现在我有这个;
sentence = input('Enter your sentence: ' )
if 'a,e,i,o,u' in sentence:
print(???)
else:
print("empty")
推荐答案
类似的事情?
sentence = input('Enter your sentence: ' )
for letter in sentence:
if letter in 'aeiou':
print(letter)
这篇关于只打印字符串中的元音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!