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

Vu Hua
Vu Hua
17,772 Points

function output without vowel (a,e,i,o,u)

Hello,

Is there anybody help me on this task? I try to apply the list method remove but my parameter is a string so I can't make it even I convert my string into a list type.

Thanks all in advance.

disemvowel.py
vowel_list=["a","e","i","o","u"]
def disemvowel(word):
    for each_word in word:
        if each_word.lower() in vowel_list:
            return word.remove(vowel)
        else:
            return word

1 Answer

A. You have to put the list inside the function

def disemvowel(word):
    vowel_list=["a","e","i","o","u"]

B. You must make a list that contains all the items in the word

word_list=list(word)

C. You must delete all vowels from the created list

for each_word in word:
    if each_word.lower() in vowel_list:
        each_word.remove(word_list)

D. You must return word after the loop is ready, or better say the word without vowel.

word="".join(word_list)
return(word)
# or just the joined list
return("".join(word_list))
Vu Hua
Vu Hua
17,772 Points

Hello reanimator313,

I can make it now. Thanks so much!

In the beginning, my "for loop" didin't check through all the word because I put the "return" of the "def" in wrong place, I put it in "if" 's block.

Now I understand. Thanks again.

VÅ©