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

Can anyone tell me what I did wrong here?

I ran this in the terminal and it works perfectly. - I've been using Python3 in the terminal btw.

disemvowel.py
print("Gimme a word. Any word.")
word = input("> ")

def disemvowel(word):
    word = list(word)
    list_of_nonos = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    for item in list_of_nonos:
        while item in word:
            word.remove(item)
    word = ''.join(word)
    return word

disemvowel(word)

2 Answers

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

your function is fine you just need to not submit it with the print statement, don't ask for input, and don't call it, the autograder does that. only do what the challenge asks.

You're right! Thanks so much!

Anders Axelsen
Anders Axelsen
3,471 Points

Nice! What does the ''.join(word) actually do in this context?

Well at the beginning of the function I take the input (word) and turn it into a list of individual characters including the spaces) with word = list(word). At the end of the function ""word = '''.join(word)"" takes the list of characters and turns it back into a single string. the '' before join is what will connect the individual characters so if I had a list of characters ['p', 'i', 'e'], ''.join(['p', 'i', 'e']) it would return 'pie'. If I did 'a'.join('p', 'i', 'e') it would give me 'paiae'.