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

mourad marzouk
mourad marzouk
5,560 Points

Disemvowel challenge

This is what I have so far but not sure why its not working.

def disemvowel(word):

for vowels in word:

    if vowels.upper() == 'A' or 'E' or 'I' or 'O' or 'U':

        word.remove(vowels)

return word

word=[input("Please put in the word you like to remove vowels from\n > ")]

disemvowel(word)

print(word)

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Hey !

You need to convert the WORD to a LIST. That is because //remove()// does not work on strings.

2 Answers

mourad marzouk
mourad marzouk
5,560 Points

Oh I thought I did when I did word=[].

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

Oh yes ! did'nt see that ! . So yeah, in that case you need to change it back to a string before u return it.!

mourad marzouk
mourad marzouk
5,560 Points

ah ok I see, how would you do that? .join?

Akshaan Mazumdar
Akshaan Mazumdar
3,787 Points

You can use join

or u can run another for loop to iterate through the list and concatenate all items together in a blank string