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

Alex Diaz
Alex Diaz
4,930 Points

I'm still getting vowels! Help

Can anyone please help me finish this code challenge, not sure what's going wrong. Thank you!

disemvowel.py
def disemvowel(word):
    vowel = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    word_list = list(word)
    for vowels in word_list:
        if vowels in vowel:
            word_list.remove(vowels)
    return "".join(word_list)

1 Answer

Hello

This may help pointing you in the right direction. You could use list as well.

def disemvowel(word):
    vowels = list("aeiou")
    for letter in word:
        if letter in vowels:
            new_word = word.replace(letter, '')
            word = new_word
    return word

new_word = disemvowel('abcdefghijklmnopqurstvwxyz')
print(new_word)
new_word = disemvowel('this is a test for vowel removal')
print(new_word)

...

If this answers your question, please mark the question as answered.