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

Adam Ryde
Adam Ryde
5,222 Points

Disemvowel

here is my code.... its late, i have been at work since 5am and i just cannot get my brain to function around this. my way of thinking was, if i put the upper and lower case values of vowels into lists of their own, i could then use those lists to find the vowels and delete them?

i am guessing i was wrong.

def disemvowel(word): vowels_lower = ["a", "e", "i", "o", "u"] vowels_upper = ["A", "E", "I", "O", "U"]

if vowels_lower in word:
    del vowels_lower
elif vowels_upper in word:
    del vowels_upper

return word
disemvowel.py
def disemvowel(word):
    vowels_lower = ["a", "e", "i", "o", "u"]
    vowels_upper = ["A", "E", "I", "O", "U"]

    if vowels_lower in word:
        del vowels_lower
    elif vowels_upper in word:
        del vowels_upper

    return word

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

this throws an error because you are asking if a list is in a string. there's a method in python (lower) that you can call on a string like myString.lower() that will return a lower-case version of myString. you can store that in a variable, cast it to a list and loop through it, removing the vowels from a copy of the list (you must avoid looping through a list that you are simultaneously modifying), or just append the consonants to a new string. either way you should end up with the correctly disemvoweled word.