私は宿題プログラムのほとんどすべてを終えました。最後の機能は、入力にある特定の母音を表示するようにプログラムを設定することです。どのように特定の母音が単語に表示されますか
Please enter a word: look
The vowels in your word are
o
o
there were 2 vowels
I'm terribly sorry if I missed any 'y's.
コード:たとえば
def main():
vowels = ["a","e","i","o","u"]
count = 0
string = input(str("please enter a word:"))
for i in string:
if i in vowels:
count += 1
print("The vowels in your word are:")
print("There were",count,"vowels")
print("Sorry if I missed any 'y's")
if __name__ == "__main__":
main()
さて、あなたは、なぜそれらを印刷しない、適切なタイミングで各母音へのアクセス権を持っていますか? –
あなたは2つのオプションがあります:1)母音を(ループで)見つけたときに母音を印刷するか、2)母音をリストに集めて後で印刷する。 – Linuxios
母音から出現数までの辞書マッピングへの母音を変更しようとします。 – afifit