def anti_vowel(text):
    string = "/".join(text)
    string_list = string.split('/')
    check = ['a','e','i','o','u']
    for x in string_list:
        for y in check:
            if x == y.lower() or x == y.upper():
    a = "".join(string_list)
    return a

print anti_vowel('Hey look Words!')

Why does not 'o' disappear from 'Words!'?


Seems like a lot of work going on with multiple redundancies.

  1. text is iterable
  2. in has more uses than just loops
  3. if we change the object case, we don't need to change the check case

If the purpose of these lines is to create a list from a string, it's the long way about it.

lst = list(text)

does the same thing. But we don't need any lists unless you are insistent upon using .remove() which comes wirh its own challenge, shifting elements.

if x.lower() in 'aeiou":

Not iteration involved (except maybe internally).


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