Anti-vowel


#1




It returns "Hey look Words!"

when it should return "Hy lk Wrds!".

Replace this line with your code. 
def anti_vowel(text):
    #text=str(text)
    #print text
    lst1="aeiouAEIOU"
    #lst2=[]
    for i in text:
        if i in lst1:
            text.replace(i,"")

    return text


#2

if you are using string.replace() you don't even need a loop, you can just tell replace to replace all vowels with nothing.


#3

I am very new to python . Can you tell me how can i replace all vowels .


#4

please don't use replace(), it takes away the point of the exercise.

You simply make an empty list (for example lst2) and then loop over text, and append constants to lst2

you could simply use not in to check if i is not in lst1


#5

Okay in that way without using replace my output is coming, but i just wanted to clear my concept what changes i have to do in my previous code to make it work , using that replace function.
here is my code without replace and its working.
def anti_vowel(text):
lst2=[]
lst1="aeiouAEIOU"
for i in text:
if i not in lst1:
lst2.append(i)
lst2="".join(lst2)
return lst2


#6

okay, maybe replace more of a challenge then i thought. Replace is easy for censor.

what you currently have is better :slight_smile:


#7

Please tell me how it will work with replace, please.


#8

Okay just tell me why it is not giving the correct output with replace.


#9

okay, never mind, i am dumb. lets get back to your original code here:

def anti_vowel(text):
    #text=str(text)
    #print text
    lst1="aeiouAEIOU"
    #lst2=[]
    for i in text:
        if i in lst1:
            text.replace(i,"")

    return text

and then in particular this line:

text.replace(i,"")

this will return a copy of the string with the removed item, but you don't store this copy of the string anywhere, if you would store the updated string simply in text:

text = text.replace(i,"")

everything would work fine


#10

Thank you so much , thanks a lot..:slight_smile:


#11