Please tell me what is wrong with my code


#1



This is to remove all the vowels. First i convert the input to a list and the remove a character if it happens to be a vowel. The error says:
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "['H', 'y', ' ', 'l', 'k', ' ', 'W', 'o', 'r', 'd', 's', '!']" when it should return "Hy lk Wrds!".
Which is why I use the join() function. But that isn't working.


 def anti_vowel(text):
    new=[]
    for a in text:
        new.append(a)
    for c in new:
        
        for x in 'aeiouAEIOU':
            if x==c:
               new.remove(x)
             
    "".join(new)  
    return new


#2

you don't store the result of the join action in a variable? so you join, but don't save this anywhere.

also, remove() is a difficult approach given you deal with index shifts which causes problems if you have successive vowels.


#3

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