vowels = 'aeiou'
words = %w(apple orange pear milk otter snake iguana tiger eagle)
index = 0
words.each do |word|
word.each_char do |char|
if vowels.include? char
char = char.upcase
word[index] = char
end
index += 1
end
index = 0
end
p words
p words == ["ApplE", "OrAngE", "pEAr", "mIlk", "OttEr", "snAkE", "IgUAnA", "tIgEr", "EAglE"]
vowels = 'aeiou'
words = "apple orange pear milk otter snake iguana tiger eagle".split()
def swap_vowels(word):
index = 0
for char in word:
if char in vowels:
word = word[:index] + char.upper() + word[index+1:]
index += 1
return word
ww = map(lambda w: swap_vowels(w), words)
out = list(ww)
print(out)
print(out == ["ApplE", "OrAngE", "pEAr", "mIlk", "OttEr", "snAkE", "IgUAnA", "tIgEr", "EAglE"])