8 anti_vowel


#1




Hi everyone!
Me again... so I've probably missed something really obvious.

My code seems to only take out the first vowel, unless it's a double (eg, look I'll get back "lk" "feed" will give back "fd", but something like "complete" I'll get "cmplete" back.)

I wonder if I understand my code or what it is I'm 'spose to be doing xD
Wait ... does that mean that it's stopping once it's found the first vowel? Do I need to write a bit to tell it to go through every letter..? (but isn't that what the for statement is for?)


def anti_vowel(text):
   vowel = "aeiouAEIOU"
   for l in text:
        if l in vowel:
           new = text.replace(l, "3")
           return new

I've also tried:
for l in "aeiouAEIOU": with no avail.

(please just ignore the "3" - I know it's not meant to be there, but I wanted to see if it was due to shifting indices/(indexes?) and not actually going through the whole word - it's not, because it'll swap the first vowel for a "3"...

Thanks :slight_smile:


#2

maybe you should read how replace works:

python doc - string replace

With replace you can simply find all vowels and replace them (in a single line), kind of boring

create a empty list/string. try looping over text, and use not in to check if the letter is not in vowel, then append the constants to the list/string


#3

How do you append to a list? With a +?


#4

you can use aList.append(item)


#5

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