Check if a string can be converted to another string by replacing vowels and consonants | Function to check if the character is vowel or not ; Function that checks if a string can be converted to another string ; Find length of string ; If length is not same ; Iterate for every character ; If both vowel ; Both are consonants ; Driver Code
def isVowel ( c ) : NEW_LINE INDENT if ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' ) : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def checkPossibility ( s1 , s2 ) : NEW_LINE INDENT l1 = len ( s1 ) NEW_LINE l2 = len ( s2 ) NEW_LINE if ( l1 != l2 ) : NEW_LINE INDENT return False NEW_LINE DEDENT for i in range ( l1 ) : NEW_LINE INDENT if ( isVowel ( s1 [ i ] ) and isVowel ( s2 [ i ] ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT elif ( ( isVowel ( s1 [ i ] ) ) == False and ( isVowel ( s2 [ i ] ) == False ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT S1 , S2 = " abcgle " , " ezggli " NEW_LINE if ( checkPossibility ( S1 , S2 ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT