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

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.