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

Sam Blaha
Sam Blaha
15,146 Points

Is this close or way off?

Am I missing some big steps here?

vowel = ('a','e','i','o','u')

def disemvowel(word):
    for letter in word:
        if letter.upper() or letter.lower() == vowel:
    return word

2 Answers

Steven Parker
Steven Parker
229,670 Points

You've got a few issues yet. When you combine tests with logic, each side of the logic has to be a complete test (two terms and a comparison operator). But you don't need two tests here because your vowels are all lower case. So you only need to compare the letter.lower().

But "remove" only works on lists, so you can't remove anything from just a letter.

Also, none of this changes "word" so if you return it at the end, you're just giving back the original word unchanged.

So what you might want to try is to either convert the word to a list, and remove things from it in the loop, and the reassemble it into a string to return — or — you could construct a new string in the loop using only the letters that are not vowels and then return that new string.

Kayla Johhnson
Kayla Johhnson
756 Points

First, you want a list of vowels - you can do this with hard brackets [] or with the list function - list(). Also, you'll want to create a list version of the word to be passed through.

You won't need both the methods .upper and .lower. Since you have provided a list of lower case vowels you can just use .lower() - that will coerce any letters pushed through the function to lower case and they will therefore be caught by your vowels list.

Instead of the == you will just put 'in' because you are checking if the letter exists in the list of vowels. == is used, as far as I know, to check that the value of one object is equal to another object. For example if you state that the variable fruit = 'apples' if you go back and 'double check' it with fruit == 'apples' you will be supplied with True.

The .remove method can be used on the list version of the word. And you'll also want to change the word back to a string at the end of the function before returning the word. You can do this with the .join method.