Anti vowel


Does your anti_vowel function take exactly one argument (a string)? Your code threw a "'int' object is not iterable" error.

def anti_vowel(text):
    vowel = "aeiouAIEIOU"
    empty = ""
    for i in len(text):
        for n in len(vowel):
            if text[i] == vowel[n]:
            empty = empty + text[i]
    return empty.join()


this loop:

for i in len(text):

len will give you the length, as integer. you can't loop over integers, just loop over `text:

def anti_vowel(text):
   for i in text:
       print i

this will give you each letter.


def anti_vowel(text):
    vowel = "aeiou"
    empty = ""
    for i in text:
        for n in vowel:
            if i.lower() == n: break
            elif i.lower() != vowel[4]: empty = empty + i
    return empty

here is my new code, but it still doesnt work.
Oh and dont mind the indentation

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


uhm... now you also loop over vowel, this means will push a lot of letters into empty. the if and elif statement are evaluated every run of the for n in vowel loop, pushing a lot of letters into empty, it would be better to use if i in vowel, this will check if i is in vowel


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