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

Function does not returning any value

I'm just trying to get the value from function "disemvowel", but this function does not returning any value.

can you please check this

disemvowel.py
word=list(input('Enter your word'))
vowels=["a","e","i","o","u"]
def disemvowel(word):
    for x in word:
        if x in vowels:
            word.remove(x)

    print(word)
    return word
disemvowel(word)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It actually does return a value (though it might not be what you want). The problem is that you call the function and pass it whatever you input, but then you don't do anything with the value it returns. It sort of just disappears out into limbo. On your last line, try this:

print(disemvowel(word))

Also, I'm assuming you're running this either in workspaces or your local system as this will likely not be testable inside the challenge.

Hope this helps! :sparkles:

Joel Sprunger
Joel Sprunger
5,448 Points

You could execute by using the following...

no_vowels = disemvowel(word) print("The word {}, has no vowels.".format(no_vowels))