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

Noah Harness
Noah Harness
1,383 Points

I suck at programming and its making me upset

I don't know how to do this shit.

disemvowel.py
blank_word = ""
vowels = ["a", "e", "i", "o", "u"]
def disemvowel(word):
    for letter in word:
        if letter not in vowels:
            blank_word += letter
            print(blank_word)

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Noah, you pretty much have the answer there :) You do know how to do it.

vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]  # have to include both upper and lower cases
def disemvowel(word):
    blank_word = ""  # better as a local variable inside the function
    for letter in word:
        if letter not in vowels:
            blank_word += letter
    return blank_word  # remember you want to return this, not print it out

if you want to avoid including capitals and lowercase letters in vowels, you can just check if char.lower() not in vowels:. That way, no matter what the case of char is, it'll still be in the list.