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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -