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

Chris Sederqvist
Chris Sederqvist
7,596 Points

[SOLVED] Not accepted by Treehouse, works fine in my environment.

Here is my code, that works fine in my environment but Treehouse refuses to accept it:

def disemvowel(word):
    vowels = ('a', 'e', 'i', 'o', 'u')
    temp = []
    for l in word.lower():
        if l not in vowels:
            temp.append(l)
    return ''.join(temp)

When I try with:

w = 'AIlaptopuiaEXOdus'
print(disemvowel(w))

it returns:

lptpxds

the probles is that you have to return word, no temp. I hope this help

def disemvowel(word):
    vowels = ('a', 'e', 'i', 'o', 'u')
    temp= word
    word = []
    for l in temp.lower():
        if l not in vowels:
            word.append(l)
        else:
            pass

    print( ''.join(word))

disemvowel('AIlaptopuiaEXOdus')

4 Answers

the problem is that you have to return word, no temp. I hope this help

def disemvowel(word):
    vowels = ('a', 'e', 'i', 'o', 'u')
    temp= word
    word = []
    for l in temp.lower():
        if l not in vowels:
            word.append(l)
        else:
            pass

    print( ''.join(word))

disemvowel('AIlaptopuiaEXOdus')
Chris Sederqvist
Chris Sederqvist
7,596 Points

Your code does not work either. Point is that my code returns the correct values, shouldn't be necessary to rename the variable returned...

I think the problem lies in the fact that you are changing the case of the input in your function.

Treehouse expects that an input of "HELLO" will return "HLL"

Your function as written takes "HELLO" and returns "hll"

Chris Sederqvist
Chris Sederqvist
7,596 Points

Well, the assignment was to make sure both upper and lowercase are handled. But... I probably misunderstood something in the text.

I move on with life after solving it like this:

def disemvowel(word):
    vowels = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')
    temp = []
    for l in word.lower():
        if l not in vowels:
            temp.append(l)
    return ''.join(temp)

Thanks for your feedback.

Chris Sederqvist
Chris Sederqvist
7,596 Points

I managed to figure out a way to solve it. See below.

Chris Sederqvist it is odd, your code works perfectly in Pycharm. I tried differents ways and neither of them passed. Maybe, it is a bug.

Chris Sederqvist
Chris Sederqvist
7,596 Points

After adding 'A', 'E', 'I', 'O', 'U' to the tuple of vowels it passes in Treehouse as well.

Chris Sederqvist I saw the change you did to your code. I pasted it in the challenge, but it didn't pass either. Very weird!!!!