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

in #python6 years ago

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.

Sort:  
UpvoteBank
Your upvote bank
__2.jpgThis post have been upvoted by the @UpvoteBank service. Want to know more and receive "free" upvotes click here

You post has been manually curated by BDvoter Team! To know more about us please visit our website or join our Discord.

Vote @bdcommunity as a Hive Witness.

Are you a Splinterlands player? If Yes, then checkout MonsterMarket.io. Get instant 3% cashback on every card purchase, and 2% cashback on every booster pack purchase on MonsterMarket.io. MonsterMarket has the highest revenue sharing in the space - 60% for cards and 40% for packs, no minimum spending is required. Join MonsterMarket Discord.

BDvoter Team

Hey @bdvoter, thanks for the upvote. I really appreciate your upvote. I voted @bdcommunity as witness too. Here is the transaction id: https://hiveblocks.com/tx/477ee5b7d82d59db52776ad8e22303aee5108670

Screenshot_1.png

Keep Supporting!!