mercredi 26 septembre 2018

Error str object not callable in vowel counting program

Hi I am trying to write a program that counts the vowels in a sentence and then prints out the count of each vowel individually.

I am getting a coding error that string object not callable in the if statement.

Any help would be be appreciated. Thanks

Sentence = input("Please enter sentence: ")
a = 0
e = 0
i = 0
o = 0
u = 0
for index in range(0, len(Sentence) - 1):
    if Sentence(index) == "a":
        a = a + 1
    elif Sentence(index) == "e":
        e = e + 1
    elif Sentence(index) == "i":
        i = i + 1
    elif Sentence(index) == "o":
        o = o + 1
    elif Sentence(index) == "u":
        u = u + 1
print(a, e, i, o, u)

Aucun commentaire:

Enregistrer un commentaire