## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

# Remove vowel function. Why isn't my code working?

The logic is there it seems. Every time it returns the word I get back the same original string. Any help appreciated.

disemvowel.py
```def disemvowel(word):
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
for letter in word:
if letter in vowels:
del letter
return word
```

Hello Ali, the thing is that word is essentially a string and strings are immutable. So try creating another string that is the initial word without the vowels, and then return it.

I've completed the challenge but in a different way. Every time I ran:

```def disemvowel(word):
vowels = ['a', 'e', 'i', 'o', 'u']
word_list = list(word)
for letter in word_list:
if letter.lower() in vowels:
word_list.remove(letter)
new_word = ''.join(word_list)
return new_word
```

It would only remove some of the vowels it detected. I'm still not sure why. For example: disemvowel("UECwoe") Would return as "ECwe"

So I figured it needed to run through all the vowels so I put a for loop for the vowels.

```def disemvowel(word):
vowels = ['a', 'e', 'i', 'o', 'u']
word_list = list(word)
for vowel in vowels:
for letter in word_list:
if letter.lower() in vowels:
word_list.remove(letter)
new_word = ''.join(word_list)
return new_word
```

Do you know why the first one wouldn't work and the second one did? Also, could you elaborate on what you mean by creating another string? Where would it be placed?

Hey, I just ment that you can't change the given string, by telling you to make another string I ment to do a list remove vowels and join it into a new string, but I just wanted to give you a hint and not the whole answer so you figure it out.

The first code would work if you had put: for letter in word_list.copy ():

we add the .copy() because when you modify the list while looping through it you can get weird results and it kinda misbehaves :) so we use a copy of the list and for every item from the copy we remove that item from the original list :)

I hope this helps

I have to remember to use copies instead. Appreciate it.