Anti_vowel


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096

It execute only twice while I need multiple times


def anti_vowel(text):
    result = ""
    count = 0
    for letter in text:
        for c in "aeiouAEIOU":
            if c == letter:
                result = result +""
            else:
                count = count+1
            while count == 10:
                result = result + letter
                count = 0
    
    return result
    
    #why did it just execute once?#


#2

Trying to get what you mean by you "need multiple times".

However, I tried to simplify the block of code.

def anti_vowel(text):
    result = ""
    for letter in text:
        if letter not in "aeiouAEIOU":
                result += letter
    return result
print anti_vowel("Hello Busy")

Hope this helps! :slight_smile:


#3

Works with lists, too:

def anti_vowel(text):
    result = ""
    vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    for char in text:
        if char not in vowels:
            result += char
    return result

#4

Absolutely, it will. Just trying to stay inline with the OP.

Thanks for the share. Benefits of a community! :slight_smile::clap:


#6

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