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

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)