codingdirectional: Count the vowel characters within a string with Python function

Hello and welcome back, we will start a new python project soon but for now, let us continue solving some python related problems first in this post and beyond.

The problem we are going to solve in this article goes like this: Given a string consists of lower case characters and spaces, you need to write a function to count the total vowel characters within that string. The solution is as follow.

 def getCount(inputStr):     num_vowels = 0     li= list(inputStr)     vovel= ['a','e','i','o','u']     for i in li:         if i in vovel:             num_vowels+=1              return num_vowels 

The above function will only count the vowel character within a string and skips the other characters.

Planet Python

Leave a Reply

Your email address will not be published. Required fields are marked *