Anti_vowel function works but not accepted print/return


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#


I have created 2 versions of the function that return correct responses, but neither pass as correct answer:

Even when I change 'print' to 'return' (as suggested in previous posts) I receive None in the viewer window but either way I still receive this error message:

Your function fails on anti_vowel("Hey look Words!"). It returns "None" when it should return "Hy lk Wrds!".

Here's my code with examples:


1. 
def anti_vowel(text):
    for c in text:
            if c not in "aeiouAEIOU":
                print c  

anti_vowel("Hey look Words!")
"""prints:
H
y
 
l
k
 
W
r
d
s
!"""


2. 
def anti_vowel(text):
    new_text = " "
    for c in text:
            if c not in "aeiouAEIOU":
                new_text += c
    print new_text

anti_vowel("Hey look Words!")
"""Returns:
Hy lk Wrds!"""

Sorry if this is a repeat question, I tried to read every single other anti_vowel post before posting.

Thank you.


#2

the first one certainly won't work, the second one is pretty good, but you print the anti_vowel string, your function should return it


#3

I got it, thanks for response.

def anti_vowel(text):
    new_text = ""
    for c in text:
            if c not in "aeiouAEIOU":
                new_text += c
    print new_text
    return new_text

#4

you can also add print in front of the function call to print what the function returns


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.