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

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.