Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Lists Disemvowel

Abdullah Jassim
Abdullah Jassim
4,551 Points

I am not sure what mistake I am doing here.

Secondly, under what circumstances can I put defining variables outside a function. For e.g. can I put this outside the function? Thank you

    vowel = ("a", "e", "i", "o", "u")
    letters = list(word)
def disemvowel(word):
    vowel = ("a", "e", "i", "o", "u")
    letters = list(word)

    for letter in word:
        if letter.lower in vowel:
            letters.remove(letter)

    return ",".join(letters)

new_word = disemvowel("australia")
print(new_word)
disemvowel.py
def disemvowel(word):
    vowel = ("a", "e", "i", "o", "u")
    letters = list(word)

    for letter in word:
        if letter.lower in vowel:
            letters.remove(letter)

    return ",".join(letters)

new_word = disemvowel("australia")
print(new_word)

2 Answers

Katherine Ebel
Katherine Ebel
43,799 Points

Sorry so late. Just went and read the challenge. They want you to return the word without vowels. You are returning the letters separated by commas. Guessing you've figured this out by now ;)

Katherine Ebel
Katherine Ebel
43,799 Points

lower is a method on string, so it should be called like: letter.lower() You just left out the parens. Change that, and it should work.

Abdullah Jassim
Abdullah Jassim
4,551 Points

Hi i just tried that but im still getting an error. Any suggestions?

def disemvowel(word):
    vowel = ("a", "e", "i", "o", "u")
    letters = list(word)

    for letter in word:
        if letter.lower() in vowel:
            letters.remove(letter)

    return ",".join(letters)