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: 
For every vowel you’re iterating through, the loop checks the condition, replaces the content in the same string and then iterates by 1 which now is the same string but instead of the next new letter, it now has to deal with 3 more of the same vowel. For example:

Let’s talk about the string ‘excellent’. For the first vowel ‘e’, it is replaced with ‘eeee’ resulting in the string being ‘eeeexcellent’, now when the second loop begins it starts at index(1) which is still an ‘e’ and this keeps going on. **Never modify the iterable you’re iterating over.**
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)

```