python 3.4 - Counts the Vowels in an input -
instead of showing how many vowels appear in ends counting them. how can fix issue?
def main(): sentence=input("please type sentence") counta=0 in sentence: if =="a": counta+=1 print("the letter appears:", counta,"times") counte=0 in sentence: if == "e": counte+=1 print("the letter e appears:", counte,"times") counti=0 in sentence: if == "i": counti+=1 print("the letter appears:", counti,"times") counto=0 in sentence: if == "o": counto+=1 print("the letter o appears:", counto,"times") countu=0 in sentence: if == "u": countu+=1 print("the letter u appears:", countu,"times") county=0 in sentence: if == "y": county+=1 print("the letter y appears:", county,"times") main()
sentence.count()
way easier, fixed you. take print commands out of loops.
sentence=input("please type sentence") counte=0 in sentence: if == "e" or == "e": counte+=1 print("the letter e appears:", counte,"times") counti=0 in sentence: if == "i" or == "i": counti+=1 print("the letter appears:", counti,"times") counto=0 in sentence: if == "o" or == "o": counto+=1 print("the letter o appears:", counto,"times") countu=0 in sentence: if == "u" or == "u": countu+=1 print("the letter u appears:", countu,"times") county=0 #or use sentence.count(letter) #for in sentence: # if == "y" or == "y": # county+=1 sentence.lower() print("the letter y appears:", sentence.count("y"),"times")
Comments
Post a Comment