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

Aleksandra Laska
Aleksandra Laska
5,343 Points

I do not understand what is wrong with this code :(

Can you please help me ?

def disemvowel(word):
    return word
    word.remove("A", "E", "I", "O", "U")

1 Answer

Darryl Mah
Darryl Mah
5,492 Points

Be careful with your return statement, based on its placement the other two lines of your function won’t run, remember that your function ends once it hits the return statement.

Good idea moving all the letters to uppercase. However, idk if this is how treehouse wants you to return the string. For example they might want to return “Hello World” back as “Hll Wrld” versus “HLL WRLD”.

For your .remove method, this only removes items from a list and not characters from a string. If you want to use this method you could put all the characters into an array, with a for in loop, and then call this method on the array. The put back together the array of letters into a string.

If you had access to re (regular expressions) it could make things simpler with the .sub method.

Hope these tips help! :)