Anty Vowels


#1



Why does not my Code work , I keep getting an error with index ? anyone please explain what should I do or what is the error so I can work a way ?

def anti_vowel(text):
    #" " join.(list) For making a list into a string
    String=[]
    Vowels="AEIOUaeiou"
    for i in range(0 , len(text)):
        String.append(text[i])
    for e in range(0,len(String)):
        for String[e] in Vowels:
            del String[e]
    return "".join(String)


Replace this line with your code.


#2

I feel as if you took it too far.. its actually fairly simple.
Here's how I did it:

def anti_vowel(text):
    removal = "" #empty string.
    vowels = ['a','e','i','o','u','A','E','I','O','U'] #list of vowels.
    for i in text: #iterates over every letter in the string.
        if i not in vowels: #If its not in the vowels in list.
            removal = removal + i #add it to the removal string
    return removal

print anti_vowel('Hey there! how you doing?') #test

Hope this helps out with your confusion :slight_smile:


#3

Thanks alot for your help :slight_smile:


#4

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