Longest Subsequence of a String containing only vowels | Function to check whether a character is vowel or not ; Returns true if x is vowel ; Function to find the longest subsequence which contain all vowels ; Length of the string ; Iterating through the string ; Checking if the character is a vowel or not ; If it is a vowel , then add it to the final string ; Driver code
def isVowel ( x ) : NEW_LINE INDENT return ( x == ' a ' or x == ' e ' or x == ' i ' or x == ' o ' or x == ' u ' ) NEW_LINE DEDENT def longestVowelSubsequence ( str ) : NEW_LINE INDENT answer = " " NEW_LINE n = len ( str ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( isVowel ( str [ i ] ) ) : NEW_LINE INDENT answer += str [ i ] NEW_LINE DEDENT DEDENT return answer NEW_LINE DEDENT str = " geeksforgeeks " NEW_LINE print ( longestVowelSubsequence ( str ) ) NEW_LINE