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

Mauro Y.
Mauro Y.
6,520 Points

This script in not passing the challenge, but working in my machine. Why?

Made this script to remove vowels from some word. Work perfectly on my system, but is been refused by the challenge terminal. The platform alert is not helping, just says: Bummer! Try again! Some idea?

disemvowel.py
def disemvowel(word):
    vogal = ['a', 'i','u', 'e', 'o', 'A', 'I', 'U', 'E', 'O']
    i = 0

    while i <= len(vogal) - 1:
        j = 0
        count = len(word)
        while count >= 0 :
            try:
                word.remove(vogal[i])
            except ValueError:
                pass
            count -= 1
        i += 1


    word = ''.join(word)

    return word

1 Answer

Steven Parker
Steven Parker
231,269 Points

This worked for you?

When I tried it, I got this:

  File "disemvowel.py", line 10, in disemvowel                                                                        
    word.remove(vogal[i])                                                                                      
AttributeError: 'str' object has no attribute 'remove' 

But if I modify the program so that it does not have this error, it also passes the challenge.

Mauro Y.
Mauro Y.
6,520 Points

Sorry. In fact the scrip is:

def disemvowel(word):
    print(word)            
    word = list(word)

    vogal = ['a', 'i','u', 'e', 'o', 'A', 'I', 'E', 'O', 'U']
    i = 0 

    while i <= len(vogal) - 1:
        j = 0 
        count = len(word)
        while count >= 0 : 
            try:
                word.remove(vogal[i])
            except ValueError:
                pass
            count -= 1
        i += 1


    word = ''.join(word)
    return word
Steven Parker
Steven Parker
231,269 Points

That's the same change I made, and it passes the challenge as-is (though you don't need to print anything).