Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,236 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)