Anti_vowel help


Hello everyone! My codes display "Hy Lk Words!" instead of "Hy Lk Wrds!" I don't know why it worked for the first two "o"s, but not the last one. Can anyone help me? thx.

def anti_vowel(text):
    checklist = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    translist = []
    for char in text:
    for n in translist:
        for x in checklist:
            if n == x:
    return ''.join(translist)
print anti_vowel("Hey Look Words!")


The code sees the first and third o but removes the first and second.


thank you very much. I understand now.
for--in loop accesses list by index and list.remove() changes the index. so an "o" is skiped.


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