Count of substrings consisting only of vowels | function to check vowel or not ; Function to Count all substrings in a string which contains only vowels ; if current character is vowel ; increment ; Count all possible substring of calculated length ; Reset the length ; Add remaining possible substrings consisting of vowels occupying last indices of the string ; Driver Program
def isvowel ( ch ) : NEW_LINE INDENT return ( ch in " aeiou " ) NEW_LINE DEDENT def CountTotal ( s ) : NEW_LINE INDENT ans = 0 NEW_LINE n = len ( s ) NEW_LINE cnt = 0 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ( isvowel ( s [ i ] ) ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( cnt * ( cnt + 1 ) // 2 ) NEW_LINE cnt = 0 NEW_LINE DEDENT DEDENT if ( cnt != 0 ) : NEW_LINE INDENT ans += ( cnt * ( cnt + 1 ) // 2 ) NEW_LINE DEDENT return ans NEW_LINE DEDENT s = " geeksforgeeks " NEW_LINE print ( CountTotal ( s ) ) NEW_LINE