Generation

generate functionTue, 13 Dec 2022

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 IN THE SAME ORDER! 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 vowel_2_index(inp): for i in range(len(inp)): if type(inp[i]) == int: if inp[i] == 97: inp[i] = "a" elif inp[i] == 118: inp[i] = "u" elif inp[i] == 105: inp[i] = "i" elif inp[i] == 111: inp[i] = "o" elif inp[i] == 101: inp[i] = "e" return inp inp = [118, "u",120,121,"u",98,122,"a",120,106,104,116,113,114,113,120,106 ] vowel_2_index(inp)

Questions about programming?Chat with your personal AI assistant