Anti_vowel


#1



This is my code but it returns this error message
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "H" when it should return "Hy lk Wrds!".

Please I need assistance

def anti_vowel(text):
    output = ""
    for c in text:
        if c not in "AEIOUaeiou":
            output.append(c)
    "".join(output)
    return output


#2

.append() only works for lists. Perhaps change your output from output = "" to output = [].
Also you're returning output without the join() being stored. Instead, do return "".join(output) or store the "".join(output) in output before returning it.


#3

That worked, I really should have seen that. Thanks a lot


#4

Just declare the output as list and later convert it to string
Like this:
output = []

new_text ="".join(output)
return new_text

#5

I don't get why my code doesn't work:

def anti_vowel(text):
rev = " "
for i in text:
if i not in "AEIOUaeiou":
rev = rev + i
return rev

print anti_vowel("carlos")

It gives me this error:

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

The error says that my code returns exactly what it should return...


#6

It returns " Hy lk Wrds!"
it should return "Hy lk Wrds!"
I see a difference. There's an extra space before the words in your return.
Make sure your rev="" doesn't have a space between the quotation marks.


#7

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