CBSE Class 11 Computer Science Question 89 of 91

String Manipulation — Question 13

Back to all questions
13
Question

Question 13

Write a program that inputs a line of text and prints out the count of vowels in it.

Solution
str = input("Enter a string: ")
count = 0

for ch in str : 
    lch = ch.lower()
    if lch == 'a' \
       or lch == 'e' \
       or lch == 'i' \
       or lch == 'o' \
       or lch == 'u' :
       count += 1

print("Vowel Count =", count)
Output
Enter a string: Internet of Things
Vowel Count = 5
Answer