For this code I pretty much have it so that it will return certain indices, but it counts multiple vowels in the same index. I just realized that index() only returns the first occurrence of the item, but now I've pretty much exhausted other possibilities.
def vowel_indices(s):
'string ==> list(int), return the list of indices of the vowels in s'
res = []
for vowel in s:
if vowel in 'aeiouAEIOU':
res = res + [s.index(vowel)]
return res
An example of this working is:
vowel_indices('hello world')
[1, 4, 7]
Instead I end up getting [1,4,4] as the return.