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

Zhang Dong Zhi
Zhang Dong Zhi
982 Points

disemvowel

can someone please help me with this question.thank you

disemvowel.py
def disemvowel(word):
    return word

1 Answer

Martynas Matimaitis
Martynas Matimaitis
10,480 Points

Hey,

I don't want to type the whole answer but you can achieve this by using regexp expressions. Python by default has a package called "re".

So after importing re the function would be re.sub("chars_to_replace", "string_to_replace_with", word)

Few ways to group different characters in this case are:

Using pipes '|' as a OR condition e.g. "a|e|i" Using [] to create a group of characters to replace "[aei]" More information about regular expressions here: https://docs.python.org/2/library/re.html

Hope this helps!