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

Disemvowel: could it be my if statement?

Is the issue that my if statement isn't iterating through word?

disemvowel.py
def disemvowel(word):
    vowels="a e i o u A E I O U"
    for letter in vowels:
        if letter in word:
        word.remove(letter)
    return word

3 Answers

nicole lumpkin
PLUS
nicole lumpkin
Courses Plus Student 5,328 Points

The input() function itself turns whatever input it receives as into a string. Try this in your editor.

number = input("Enter any number int or float. ")
type(number)

Get it!?! :)

What might be wrong here??

def disemvowel (word): word=list (word) vowels=["a","e","i","o","u","A","E","I","O","U"] for letter in vowels: if letter in word: word.remove(letter) word=str(word) return word

nicole lumpkin
PLUS
nicole lumpkin
Courses Plus Student 5,328 Points

Here are a few things to get you on the right track. In your fifth line of code you're missing an indent. Also you are trying to use the .remove() method on word, which is a string. The .remove() method is a list method! Do you remember from previous lessons the string method that allows you to convert a string into a list!? From there you can totally use the .remove() method :)

Hope this helps!

ok.... cool. But what indicates the argument is by default string? I thought that it was just a variable that could be anything unless specified otherwise by like a try block or something.

nicole lumpkin
PLUS
nicole lumpkin
Courses Plus Student 5,328 Points

You're sooooo close!!! Here is the code you just submitted:

def disemvowel (word): 
    word=list(word) 
    vowels=["a","e","i","o","u","A","E","I","O","U"] 
    for letter in vowels: 
        if letter in word: 
            word.remove(letter) 
    word=str(word) 
    return word
disemvowel("mooc")

Your problem lies in the 4th and 5th lines of code! Go ahead and copy/paste your code into pythontutor.com and see where things go wrong!! If you can't figure it out walk away and view with fresh eyes. And If you're totally over it I'll give you the answer :) PS. Just keep plugging away. By trade, I'm a personal trainer, who's teaching herself you to code just like you!! Good luck

Ill give it my best....thanks for the help its really appreciated