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

Diego Dillon
Diego Dillon
655 Points

How to Remove a single word vowel from a word (function)

def disemvowel(word) disemvowel.remove("a","b","c","e","o","u") return word

disemvowel.py
def disemvowel(word):
    disemvowel.remove("a","e","i","o","u")
    return word

1 Answer

santosh kumar peddineni
seal-mask
.a{fill-rule:evenodd;}techdegree
santosh kumar peddineni
Python Web Development Techdegree Student 2,661 Points

the above code will not work, but can you try this take a word argument and then convert it to a list. now you have two list one with your input and the other being the vowels now compare them and if are equal you can remove that particular value. and at last return the word as a string. i will post the code only use it if needed

def disemvowel(word):
    word_list = list(word)
    for i in word_list:
        for j in ['a', 'e', 'i', 'o', 'u']:
            if i == j:
                word_list.remove(i)
    word = "".join(word_list)   
    return word