Anti_Vowel


#1

I dont know why this does not work ??

def anti_vowel(text):
    
    lst = []
    for v in lst:                
        if v in "aieouAEIOU":
           # v.remove(text)
           lst.remove(v)
           lst.append(v)
    return "".join(lst)
            
    print anti_vowel("Hey look Words")

#2

if you place the function call outside the function, you can actually see what your function is doing.

well lets start here:

for v in lst:

looping over an empty list means there is nothing to iterate, the loop will never run


#3

This is what I did now, still error

def anti_vowel(text):
    
    lst = []
    for x in text:                
        if x in "aieouAEIOU":
           #x.remove(text)
           text.remove(x)
           text.append(lst)
    return "".join(text)
            
    print anti_vowel("Hey look Words")

#4

if you followed this suggestion you would have seen the following error message:

File "python", line 7, in anti_vowel
AttributeError: 'str' object has no attribute 'remove'

lets look at line 7:

text.remove(x)

what is text? text is a string (object), strings are immutable in python, you can't use remove() method on strings.


#5

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