Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Lists Disemvowel

Thananjaya Chakravarthy
Thananjaya Chakravarthy
4,672 Points

how to remove vowels?

i have also tried with the for loop and if loop... but cannot ablt to get the output... can any one help me out with this one?

def disemvowel(word):
    for n in word:
return n

1 Answer

Here's a way I thought of...

def disemvowel(word):
    result = ''
    for letter in word:
        if letter.lower() not in 'aeiou':
            result += letter
    return result

All I'm doing here is I'm going through every letter in the string and checking to see if it's not a vowel. If it's not a vowel, we will append the letter to the result. Finally we return the result.

I hope this helps :grin:

Happy C0D1NG! :tada:

:dizzy: ~Alex :dizzy: