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

Omid Ashtari
Omid Ashtari
4,813 Points

cannot figure out what I've done wrong for Disemvowel

Thought I had most of this correct, then got a little help from the only other 'help' question about this, but still stuck. Any guidance is appreciated.

def disemvowel(word): vowels = list('aeiou') newWord = list(word) newerWord - newWord.lower() for vowel in vowels: while vowel in newerWord: try: newerWord.remove(vowel) except ValueError: break s = '' word = s.join(newerWord) return word

disemvowel.py
def disemvowel(word):
    vowels = list('aeiou')
    newWord = list(word)
    newerWord - newWord.lower()
    for vowel in vowels:
        while vowel in newerWord:
            try:
                newerWord.remove(vowel)
            except ValueError:
                break
    s = ''
    word = s.join(newerWord)
    return word

2 Answers

def disemvowel(word):
    result = ''
    for letter in word:
        if letter  not in 'aeiou':
            result += letter
    return result

How this works:

The program goes through every item in the string, and if the letter is not in 'aeiou', add the letter to a variable called result. When the loop finishes, return the result variable which is the string disemvoweled. :smile:

I hope this helps. ~Alex