Question: I am trying to write a function that takes a string as input and returns a string with all vowels repeated 4 times. 

*eg: `apple` becomes `aaaappleeee`*

It works for every vowel, except for *e*, in which it repeats *e* an egregious amount of times.

Python 3. I have tried playing with the replace function, changing the replacement value to `i+i+i+i`, `i*4`, `i(4)`, `(i+i)*2`, but nothing seems to help. 

```
def exclamation(string):
    for i in string:
        if i in 'aeiou':
            string = string.replace(i, i*4)
    return string + '!'

```

`exclamation('excellent')` should return `eeeexceeeelleeeent!`

however, it returns:
 `eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeexceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeent!`

As stated, the function works fine for all other vowels, except *e*.

Thank you!

Answer: 
You shall never modify something you're iterating over, store the modified word in a new variable. Modifing your code it would be something like

```
def exclamation(string):
    new = ''
    for i in string:
        if i in 'aeiou':
            new += i*4
        else:
            new += i
    return new + '!'

```
It's not that `e` is being treated differently, but rather that you're replacing each `e` with `eeee` for as many `e`s as there are in the word. If you try other words with multiples of the same vowel, you would see the same behavior there.

Instead of replacing for each vowel in the string, you should be doing each replacement once, which will effect every instance of that vowel in the string:

```
def exclamation(s):
    for vowel in 'aeiou':
        s = s.replace(vowel, vowel*4)
    return s + '!'

print(exclamation('excellent'))
# 'eeeexceeeelleeeent!'

```

Note that this only works if the word is already lowercase (though that would be easy to fix, add capital vowels to the loop). 

Another way of doing this would be to define a translation table to do all of the replacements at once:

```
trans = str.maketrans({vowel: vowel*4 for vowel in 'aeiou'}) 

def exclamation(s):
    return s.translate(trans)

```