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

What is wrong with my code? Python

"OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then returns that word at the end. I need you to make it so, inside of the function, all of the vowels ("a", "e", "i", "o", and "u") are removed from the word. Solve this however you want, it's totally up to you!"

I don't understand what I am doing wrong. I've made the vowels variable, i turned word into a list, I then changed word further by lowercasing everything inside.

my for loop looks ok and I turned word back into a string... HELP!!

Thanks

disemvowel.py
def disemvowel(word):
    vowels = ['a', 'e', 'i', 'o', 'u']
    word = list(word)
    word = word.lower()
    for letter in word:
        if letter in vowels:
            word.remove(letter)



    return ''.join(word)

You need to call word.lower() before turning it into a list.

Hi Garett,

That still doesn't work

Works fine when I run it: https://repl.it/I2dq/0

Hi Garett

On your link, when I run the code with the string argument("aeiou") I get back "eo"

Oh, I see the problem. You're running for loop over word while resizing the word, which causes some letters to be skipped.

Check this updated link for a working version: https://repl.it/I2dq/1

Hi Garett,

Your code is still returning vowels

Looks like I saved the wrong version.

https://repl.it/I2dq/3