Anti_vowel


#1


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

What's the problem here?


def anti_vowel(text):
     lst = []
     lst.append(str(text))
     for a in lst:
         if a == "A" or a == "a":
             lst.remove(a)
         
         elif a == "E" or a == "e":
             lst.remove(a)
         
         elif a == "I" or a == "i":
             lst.remove(a)
         
         elif a == "O" or a == "o":
             lst.remove(a)
         
         elif a == "U" or a == "u":
             lst.remove(a)
        
     "".join(lst)
              
     return lst
             
             

         
         
print anti_vowel("Hey look Words!")


#2

The List.remove() method is best used on a list that we are not iterating. Before reaching for the built-ins, see if you can write a method that uses a basic algorithm to build a new string.


#5

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