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

disemvowel challenge

I'm literally always getting stuck with these challenges i don't get it... this is what i have so far and i'm lost

def disemvowel(word):
    vowel = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U']
    for vowel in word:
        if vowel in word:
    return word
30,751 Points

I'm afraid .remove does not work on strings, however you can use .replace to replace the vowels with an empty string. Like this:

string= "example"
string.replace("e", "")
print (string)

would output xampl, replacing the e character with empty strings.

1 Answer

The way I completed the challenge

  1. deconstruct word with list function and assign to list_of_word. This way you can construct your for loop to sound like *for character in list_of_word: *
  2. Then follow through with conditional logic if character is in the vowels list then continue loop without doing anything. Else use your += to build characters into a new word variable without vowels.

Essentially you are breaking down word into its pieces then rebuilding with the pieces that don't fall out

Hopefully this interpretation helps.