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

hmmm, removing vowels isn't as easy as you might think.

So I have to remove all vowels from the word and also check for upper/lower case!

disemvowel.py
def disemvowel(word):
    word.remove("a", "e", "i", "o", "u")
    word.lower(remove("a", "e", "i", "o", "u"))
    word.upper(remove("a", "e", "i", "o", "u"))
    return word

By the way, thanks for the video Sharla!

2 Answers

Get some for loop action in there! Remember that if your word is a string you gotta turn it into a list if you want to change it b/c strings don't put up with that. You can turn it back into a string with the join method. I'm not sure what the exact parameters of the quiz are, but I'd try just making the whole word .lower() at the beginning and solve the case problem that way. Obviously, the vowels you compare against need to be lowercase, too.

here's some pseudocode to get you started:

lowercase word and make it a list

for letter in word:
   if letter is in list/str of vowels:
          remove letter 

rejoin word into string

oh man, I don't get your pseudocode. --> Total rookie here <-- I believe I've now made the WORD lowercase and into a list... But the 'for letter loop in word:' Yikes, I don't even know man!

The challenge states:

OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then returns that word at the end. I need you to make it so, inside of the function, all of the vowels ("a", "e", "i", "o", and "u") are removed from the word. Solve this however you want, it's totally up to you! Oh, be sure to look for both uppercase and lowercase vowels!


and gives this to start:

def disemvowel(word): return word