8.anti_vowel


#1



Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hy lk Words!" when it should return "Hy lk Wrds!".


Why there is still one 'o' in my return value?


def anti_vowel(text):
    text_list = []
    new_text = ""
    for c in range(len(text)):
        text_list.append(text[c])
    for i in text_list:
        if i in "aeiouAEIOU":
            text_list.remove(i)
    for letter in text_list:
        new_text += letter
    return new_text


#2

This is the stage where we can append to a new_list only those letters not in the vowel string. We don't need a starting list, just the text itself. Watch the rest of the code melt away.


#3

Thanks first!
You mean like this:
def anti_vowel(text):
text_list = []
new_text = ""
for c in range(len(text)):
text_list.append(text[c])
for i in text_list:
if i not in "aeiouAEIOU":
new_text += i
return new_text
Right?This method does work.But what if I just want to add all the letters of the text into the text_list then remove those vowels?I want to know what's wrong with the previous code.(Why can't I display my reply with indent?)


#4

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