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

I can't pass this challenge. I don't know what is the problem of it.

help

disemvowel.py
def disemvowel(word):
    new_list = word.split(", ")

    for letter in new_list.copy():
        if letter.lower()=='a':
            new_list.remove(letter)
        elif letter.lower()=='e':
            new_list.remove(letter)
        elif letter.lower()=='i':
            new_list.remove(letter)
        elif letter.lower()=='o':
            new_list.remove(letter)
        elif letter.lower()=='u':
            new_list.remove(letter)
        else:
            pass

    return ", ".join(new_list)

1 Answer

mayan porat
PLUS
mayan porat
Courses Plus Student 2,144 Points

I think the use in split method is the problem. The method returns a list of strings after breaking the given string by the specified separator, if a separator given, the string splits at a specified separator. For example if your word value is: "I,learn,python" and you use word.split(",") then the list would be: ['I', 'learn', 'python'], but if your word value is: "WindOw" then word.split(",") outcome would be ['WindOw'] because there are no "," separators in the string. Since in this challenge the origin word letters are not separated by "," in your code 'new_list' is actually a single value list that contains the entire word the function got.

I think you should use list(word) here, the list(x) method creates a list of x string's elements.