8. anti_vowel ANTI ME!


#1

please help me to understand how can i express my thoughts so that python understands it.
there is another topics but people wright down so crazy codes that impossible to get it. yes ok i know there is python genius and want to show what they can i appreciate it but for newbies it is frustrating . thanks in advance for any help. :))) hamburger to first usefull answer


vowels = ['a','e','i','o','u','A','E','I','O','U']
def anti_vowel(text):
    for w in text:
        if w == vowels:
            text.remove(w)
        return text

print anti_vowel("Hey look Words!")

the code is not the best and not till the end as i am stuck.

i want to say python that i have list of black Letters* and do not want to include them into my text. if it is so then delete them or replace with space line that counts back and no more free space.


#2

@coding_botan

Here's a commenting code

def anti_vowel(text): #we create a function called anti_vowel with text as argument
    anti = "" #we create anti variable that is going to contain every letter that are not a vowel, for the moment it is empty
    for i in text: #we create a for loop inside text
         if i not in "aeiouAEIOU": #we test if i is not a vowel
            anti = anti + i #we add the consonant in anti
    return anti #we return the value of anti after the loop

#3

yes i am now on trails again, thank you very much miniApple :slight_smile: here is your :hamburger:

also i made list vowels = ['a','e','i','o','u','A','E','I','O','U'] and add it to * if i not in vowels *

now everything is clean. have a nice day :slight_smile:

ps: i did make list because in future i want to add blacklisted words there and take of all bad words, in this way hope this little code will help me make more secure things rather then using list items.


#5