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

Daniel Evans
Daniel Evans
1,812 Points

Disemvowel.py Code below always returns a string with now vowels....Not sure what is wrong?

def disemvowel(word): words = word.lower() words = list(words) vowels = ['a','i','e','o','u'] li = [] for i in words: if i in vowels: continue else: li.append(i) new = ','.join(li) return new

disemvowel.py
def disemvowel(word):
    words = word.lower()
    words = list(words)
    vowels = ['a','i','e','o','u']
    li = []
    for i in words:
        if i in vowels:
            continue
        else:
            li.append(i)
    new = ','.join(li)
    return new

1 Answer

Rich Zimmerman
Rich Zimmerman
24,063 Points

You're returning a string with commas between each letter. Try

"".join(li)
# rather than
",".join(li)

.join will join each item in a list with whatever is in the quotes, empty quotes (no space) will put literally nothing between each item of the list and return as a string.

You may also want to, instead of

word = word.lower()

# you might want to try
if i.lower() in vowels

So if any capital letters are passed in the argument, they will be returned as capital letters.