Dremendo Tag Line

Input sentence and count total number of vowels present in it in Python

String Methods - Question 1

In this question, we will see how to input a sentence and count the total number of vowels present in it in Python programming. To know more about string methods click on the string methods lesson.

Q1) Write a program in Python to input a sentence and count the total number of vowels present in it.

Program

vc=0
vowels='aeiou'
str=input("Enter a sentence\n")

for ch in str:
    ch=ch.lower()
    if vowels.find(ch)>=0:
        vc=vc+1

print("Total vowels =",vc)

Output

Enter a sentence
I am learning Python
Total vowels = 6
video-poster