Given an array of numbers, check if any of the numbers are the character codes for lower case vowels (a, e, i, o, u). If they are, change the array value to a string of that vowel. Return the resulting array. Example: Input: inp = [118, "u",120,121,"u",98,122,"a",120,106,104,116,113,114,113,120,106 ] Output: [118,117,120,121,117,98,122,97,120,106,104,116,113,114,113,120,106 ]
def replace_vowels(vowels): vowel_codes = [97, 101, 105, 111, 117] # a, e, i, o, u result = [] for vowel in vowels: if isinstance(vowel, str): result.append(vowel) elif vowel in vowel_codes: result.append(chr(vowel)) else: result.append(vowel) return result inp = [118, "u",120,121,"u",98,122,"a",120,106,104,116,113,114,113,120,106 ] print(replace_vowels(inp))