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.

Start your free trial

Python Python Collections (2016, retired 2019) Lists Disemvowel

using the .remove() function

I'm trying to use the .remove() function here but is not working , don't know why

disemvowel.py
def disemvowel(word):

    return word
disemvowel.remove("a","e","i","o","u")

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Mathew,

you should not use the remove method on the function name. The challenge wants you to remove "a","e","i","o","u" or "A","E","I","O","U" from the string that will be passed to disemvowel method. So you should create a list inside the method with all the characters that should be removed and compare every single character with that list.

Since strings are immutable, I would also suggest creating a new variable that holds a list version of word. Create a for loop that loops over word (not its list version) and compares every character with the members of the list that should be removed. If you find one, remove it from the list version of a word ... this is important because you will modify the list version but loop over the string word. This will prevent you from skipping letters by changing their indexes ... At the end return the list version that was modified ...

Check this post. The answer that was contributed by Alex Wootton is just amazing.

This challenge is a little bit tricky so shout out if you need help or a code example. And sorry for my English ...

Thanks Grigorij