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

shekhar bhardwaj
seal-mask
.a{fill-rule:evenodd;}techdegree
shekhar bhardwaj
Full Stack JavaScript Techdegree Student 12,373 Points

It's working as expected in my ide, please if anybody can let me know what is that I am missing.

I have tested my code in my ide and it's working as expected -

def disemvowel(word): print("The Word is {}".format(word)) list_word = list(word) print("The List Word is {}".format(list_word)) vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] for vowel in vowels: if vowel in list_word: try: print("The removing vowel is {}".format(vowel)) list_word.remove(vowel)
print("the word is {}".format(list_word)) except ValueError: pass disemvowel_word = "".join(list_word) print("The returning Word is {}".format(disemvowel_word)) return disemvowel_word

def print_the_word(): print(disemvowel(raw_input(">")))

print_the_word()

disemvowel.py
def disemvowel(word):
    list_word = list(word)
    vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
    for vowel in vowels:
        if vowel in list_word:
            try:
                list_word.remove(vowel)   
            except ValueError:
                pass
    word = "".join(list_word)
    return word

1 Answer

shekhar bhardwaj
seal-mask
.a{fill-rule:evenodd;}techdegree
shekhar bhardwaj
Full Stack JavaScript Techdegree Student 12,373 Points

never mind i found my issue, I was not taking care of recurrences -

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

    for vowel in vowels:
        while vowel in list_word:
            list_word.remove(vowel)

    word = ''.join(list_word)
    return word