Answer to Question #225675 in Python for Ankita

Question #225675

Write a program to count Vowels and Consonants in string.


1
Expert's answer
2021-08-12T16:25:19-0400
def IsVowel(ch):
    return (ch.lower() in ['a', 'e', 'i', 'o', 'u'])

source = input()
vowels = 0
consonants  = 0
for ch in source:
    if(ch.isalpha()):
        if(IsVowel(ch)):
            vowels += 1
        else:
            consonants += 1

print('The number of vowels is', vowels)
print('The number of consonants is', consonants)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS