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

walter fernandez
walter fernandez
4,992 Points

OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then

i dont understand what this means, please, can someone explain it to me (I dont want a code i just dont know what the problem tell me to do) THANKS.

disemvowel.py
def disemvowel(word):
    word = ("a", "e", "i", "o","u")
    if word = word.upercase():
        word.remove()
    else word = word.lowercase():
         word.remove()


    return word

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,457 Points

Here is how I read the challenge:

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.:

def disemvowel(word):

    # -- add code here --

    return word

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.

The challenge is asking you to add code that will remove the upper and lower case vowels from the word argument passed in.

Since strings are immutable, you can't alter the strings pointed to by word. So, first off, the starting code should really look more like:

def disemvowel(word):

    # -- add code here --

    return no_vowel_word

where it is more obvious that the object returned is not the same as the word provided.

To create the no_vowel_word you will need to:

  • loop over each character in word
  • if it is a lower- or uppercase-vowel, ignore the character
  • if it is not a vowel, then save the character to be returned
  • after loop, return all the saved characters as a single string

As the challenge says, Solve this however you want, it's totally up to you! So don't worry about style at first. Later we can look at how to improve your solution.

Post back if you need more help. Good luck!