Here's the code:
vowels = ['a','e','i','o','u']
def anti_vowel(text):
tlength = len(text)
words = []
result = ""
for word in range(len(text)):
words.append(text[word])
print words
for index, word in enumerate(words):
if word.lower() in vowels:
words.pop(index)
for old_word in words:
result += str(old_word)
return result
print anti_vowel("Hey look words!")
Expected result: "Hy lk wrds!" Apparent result: "Hy lok words!"
I'm not able to figure out why is the loop skipping the 'o' on index 5 in the list words. I know I could do this another way by appending non-vowel words to a list and combining them but I want to know how to get the desired result for the above code.