Anti_vowel works in Spyder but not in Codeacademy


#1

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

Here's my code:

def anti_vowel(text):
    anti=""
    for i in text:
        if i.lower() not in ["a","e","i","o","u"]:
            anti= anti + i
    print(anti)

This works perfectly afaik. I am using Spyder with Python 3.6.0 |Anaconda 4.3.1 (x86_64)
and when I input
anti_vowel("Hey look Words!")

I get
Hy lk Wrds!

In Codeacademy get this error message instead:
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "None" when it should return "Hy lk Wrds!".

Why does the exact same code work in Spyder but not in Codeacademy? Or am I missing something entirely?


#2

try using return rather than print. I find that's a common issue with these exercises.


#3

This worked just fine thank you!
I'll make sure to use return in functions from now on, even if the output is a string.


#4

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