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

help at vowel function

Here I added the main function to test it still if try a word like this 'alikijioki' not all vowel well be removed!!!! def remove_list(word): word=list(word) for letter in word: if letter.lower() in "aouie": word.remove(letter)

return word

def main(): text=input("your word " ) print(" this is ur word {} ".format(remove_list(text)))

main()

disemvowel.py
def disemvowel(word):
    word=list(word)
    for letter in 'aieou':
        if letter.lower() in word:
            word.remove(letter)
    return(word)

1 Answer

Christopher Shaw
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 Points

There are a couple of things.

  1. Strings are immutable, so you cannot change or delete a letter, without recreating the whole string

  2. Your case testing will not work as you are saying the lower case value of the vowels which are lower case anyway. You need to lowercase the letter from the word.

def disemvowel(word):
    newword = ''
    vowels = 'aieou'
    for letter in word:
        if letter.lower() not in vowels:
            newword += letter
    return(newword)