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

gurinder singh
PLUS
gurinder singh
Courses Plus Student 1,422 Points

why its not true ??? remove!!

remove

disemvowel.py
def disemvowel(word):
    word.lower()
    word.remove ('a')
    word.remove ('e')
    word.remove ('i')
    word.remove ('o')
    word.remove ('u')

    return word

2 Answers

Steven Parker
Steven Parker
231,236 Points

You've got a few issues here:

  • "remove" is not a string method (you might be thinking of lists)
  • even if you convert the string into a list, "remove" only takes away the first item that matches
  • "lower" does not change the string you apply it to (it creates a new one with the changes)
  • you don't want to lower the entire string anyway, letters not removed should remain as they are
Péter Juhász
Péter Juhász
4,768 Points

Since strings are immutable, you cannot change it. You can create a new string and return the new one. You can start with an empty string and use a for cicle. If the character is a consonant then add to the new string. After the for cicle return the new string.