Minimum cost to convert given string to consist of only vowels | Function to find the minimum cost ; Store vowels ; Loop for iteration of string ; Loop to calculate the cost ; Add minimum cost ; Given String ; Function Call
def min_cost ( st ) : NEW_LINE INDENT vow = " aeiou " NEW_LINE cost = 0 NEW_LINE for i in range ( len ( st ) ) : NEW_LINE INDENT costs = [ ] NEW_LINE for j in range ( 5 ) : NEW_LINE INDENT costs . append ( abs ( ord ( st [ i ] ) - ord ( vow [ j ] ) ) ) NEW_LINE DEDENT cost += min ( costs ) NEW_LINE DEDENT return cost NEW_LINE DEDENT str = " abcde " NEW_LINE print ( min_cost ( str ) ) NEW_LINE