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

Conrad Cortes
Conrad Cortes
8,418 Points

disemvowel help

I'm working on this task and I'm trying to come up with a solution with out getting too much help. I have an idea of running a while loop that will keep running until it pulls all the "a's" out of a word and then it will move on to another while loop that will pull the "e's" out and so on... I'm sure this isn't the best way to do this challenge but I'm really trying to fully understand while loops. Right now I'm trying to run this in my own computer terminal and I can't figure out exactly what I'm missing to get it to pull just "a's" out of an inputted word...

def disemvowel(word):
    word = input("type word")
    while True:
        word.remove('a')
        return word
        print (word) 

disemvowel(word)    
AJ Salmon
AJ Salmon
5,675 Points

Hey Conrad! You don't need to use input() or a while loop for this one. In this case you just want to remove all vowels from a word, then return it. You'll be much better off using if. Remember, functions take an argument, and that argument is passed to the function inside the parentheses after the function is called. So, whenever you use the parameter word inside of this function, you're telling it, "Hey, whatever I do to this placeholder word, do to whatever argument gets passed to you later on." Hopefully this can get you a better start, if you have any more questions feel free to ask :)

1 Answer

Steven Parker
Steven Parker
231,236 Points

Here's a few hints:

  • you don't need both an argument and an input, but for the challenge, you use only the argument
  • you would normally use a conditional expression with a loop to keep it from running forever
  • a "return" without any conditional will stop a loop on the first item, so it won't actually be a loop
  • you can only use the "remove" method on lists, it doesn't work on strings
  • there is a string method named "replace" that might be useful
  • for the challenge, you won't need to print anything; but you will need to "return" the result