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

Jaxon Gonzales
Jaxon Gonzales
3,562 Points

Disemvowel Not working- I've tried in workspaces but nothing happening

I cannot seem to pass this code challenge. My code seems fine because when I copy and paste it into workspaces it works fine but the code challenge won't accept it. Any help is appreciated!

disemvowel.py
def disemvowel(word):

    words = list(word)

    vowels = ["a", "e", "i", "o", "u"]

    for letter in words:
        if letter.lower() in vowels:
            words.remove(letter)

    words = "".join(word)
    return words
Robert Baucus
Robert Baucus
3,400 Points

I have had the same problem in the past. My best guess would be to copy and paste your code into an IDE to check that here is not some hidden spaces that are messing you up. I use Notepad ++ and turn on "show spaces", that way I can see all the spaces and tabs that have been typed as a little dot instead of just blank space.

There might be a way to turn on 'show spaces/tabs' within the workspace, I have not tried though.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,426 Points

You are very close! It's not a good practice to modify the iterable driving the for loop. It causes indexes to get improperly shifted.

Instead, use a copy of words simply by creating a slice: words[:] in the for loop statement

The join argument should be the modified words list instead of the original argument word

Post back if you need more help. Good luck!!