Count of substrings consisting only of vowels | Function to check if a character is vowel or not ; Function to check whether string contains only vowel ; Check if the character is not vowel then invalid ; Function to Count all substrings in a string which contains only vowels ; Generate all substring of s ; If temp contains only vowels ; Increment the count ; Driver code
def isvowel ( ch ) : NEW_LINE INDENT return ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) NEW_LINE DEDENT def isvalid ( s ) : NEW_LINE INDENT n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( not isvowel ( s [ i ] ) ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def CountTotal ( s ) : NEW_LINE INDENT ans = 0 NEW_LINE n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT temp = " " NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT temp += s [ j ] NEW_LINE if ( isvalid ( temp ) ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = " aeoibsddaaeiouudb " NEW_LINE print ( CountTotal ( s ) ) NEW_LINE DEDENT