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

Yo! I know that probably there'r few better ways to solve that but i decided to don't check other guys codes on forum for this case.

My code, for some reason, isn't cutting off 'o' in 'Words!' phrase and i dont know why is that. Beside it works well (for eg. it cuts off the 'o' letters in 'Look' phrase).

Any chance for help?

def anti_vowel(text):
    a = []
    for letter in text:
        print a
    for b in a:
        if b == 'o' or b == 'u' or b == 'i' \
        or b == 'e' or b == 'a' or b == 'O' \
        or b == 'U' or b == 'I' or b == 'A' \
        or b == 'E':
    print '\n'
    print a
    o = len(a)
    print o
    while o >= 0:
        i = str()
        for x in a:
            i = i + x
            o = o - 1
            print i
        return i


anti_vowel('Hey look Words!')


When a value is removed from the list, all elements to the right are shifted one space to the left. Since the current space has been examined, the pointer goes to the next space, thereby skipping a value.

list.remove removes the first target value it encounters. When the first o in look was removed, the second one shifted, and consequently skipped. When the o in words is encountered, it is the second o in look that gets removed.

No need to build a. We can convert a string to a list with the list function.

a = list(text)

However, since text is a string, it has no ties to the caller scope and can be re-used...

text = list(text)

Your function should print anything, only return a string with vowels stripped.

This is a lot of logic that can be replaced with a single in expression.

if b in "aeiouAEIOU":


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