PRACTICE MAKES PERFECT anti_vowel | Error Message


#1

def anti_vowel(text):
   no_vowel= ' '
   for letter in text:
       if letter != 'a' and letter != 'e' and letter != 'i' and letter != 'o' and letter != 'u' and letter != 'A' and letter != 'E' and letter != 'I' and letter != 'O' and letter != 'U'  :
           no_vowel = no_vowel+letter
   return no_vowel


print(anti_vowel("Aeroplane"))

Why is it showing the error?
My code is working properly!


#2

lets replace the spaces with underscores:

_Hy_lk_Wrds

as you can see, you have leading space which shouldn’t be.


#3

It was not in the instruction to put underscores as replacement of the vowels !Capture


#4

its not, i just used the underscores to demonstrate you have a leading space which you shouldn’t have. Spaces are so difficult to see


#5

I think you need to remove the space in no_vowel = ' ' try setting it to no_vowel = '' <— no space

Also, you can condense your code a lot by doing this:

def anti_vowel(text):
    no_vowel = ""
    for letter in text:
        if letter not in "AEIOUaeiou": #dont have to check each letter individually
            no_vowel = no_vowel+letter
    return no_vowel

#7

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