COUNTING THE NUMBER OF VOWELS FROM GIVEN USER INPUT SENTENCE IN PYTHON!!

Words
77
Reading
1 min
Listen
Play
6y

Well this is a simple program written in python which asks user to input sentence and the code will count the number of vowel letter in the sentence. What each steps do, I have clearly written out by commenting just above the line of code.

#To ask for input from user
Sentence=input("Enter a sentence: ")

#To convert the user input sentence to lower case
Lower_case_sentence=Sentence.lower()

#To print the lower case sentence
print(Lower_case_sentence)


vowel_list=['a','e','i','o','u']

#initializing the count variable to 0
count=0 
for alphabet in Lower_case_sentence:
    
    #For checking if the character in the user input sentence is in vowel_list defined above
    if alphabet in vowel_list:
        
        #Incrementing the count by 1 if vowel letter found in the user input sentence
        count=count+1 
      
#To print the number of vowel letter in the sentence netered by the user       
print("The number of vowels in given sentence is: ",count)   

The output when I executed this program is as follows. I recheck the program again because it shows the correct output in the very first attempt haha.

Screenshot_5.png

Run this code online here.

COUNTING THE NUMBER OF VOWELS FROM GIVEN USER INPUT SENTENCE IN PYT... | Ecency