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


Guys I don't know where to start on task... this challenge is brain storming me I don't know where to begin...please help with the code its been 2 days kkkk

def disemvowel(word):
    return word

2 Answers

Eric M
Eric M
11,545 Points

Here's the checking part you'll need

#loop through the characters
for c in word:
        #check to see if we have a non-vowel
        if not (c in "aeiou") or (c in "AEIOU"):
                #it's a consonant

Once you get all the letters that match the non a vowel pattern, you'll need to return them as a string.

Maybe review the videos (and be sure to do the workspaces!) if you're still having trouble

Eric M
Eric M
11,545 Points

A string is just a list of characters, so you can loop through each character using something like:

for c in word:
        #your code here

For each character, use an if statement to see if it matches the condition you're checking for. In this case we want to see if something isn't a vowel, if it's not a vowel it belongs in the string we want the function to return. If it is a vowel we don't need it to be part of the returned string.

That's just one way to do it. You could also slice the string whenever you see a vowel to remove it!

Let me try and get back to you soon

I can't get it write man...can you provide the code kkk