Anti_vowel


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096


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


I expect my function to delete all of the vowel. I do not undestand why my function the last 'o'


def anti_vowel(text):
    voyl = ['a', 'e', 'i','u','o','A', 'E', 'I', 'O', 'U']
    nvliste = list(text)
    for i in voyl:
        for j in nvliste:
            if i == j:
                nvliste.remove(j)
            
    str1 = ''.join(nvliste)           
    return str1


#2

index shifts causes a second successive vowel to be skipped

so look causes problems

remove will remove the first o it can find so when the o in word is found, the o of lok (which was skipped) is removed

remove is a difficult approach

use the opposite approach, append consonants to a new list


#4

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