Python Python Collections Lists Disemvowel

Marie Spreitzer
Marie Spreitzer
1,268 Points

Please, someone check my code and help me figure out why it doesn't work!

I know I could have coded it in an easier way but I am still trying to figure out why it doesn't work here.

Thankssss :))
def disemvowel(word):
    list = word.split()
    for letter in list:
        while True:
            except ValueError:
    word = " ".join(list)
    return word

1 Answer

  1. When you split the list in your code, it is not returning a list of letter but a list of words.. so if you were to input "apples" as the word parameter your list variable would be ['apples'].

  2. The list.remove("aeiouAEIOU") only works if the word parameter is equal to "aeiouAEIOU"

def disemvowel(word):
    letter_list = list(word)
    vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    for letter in letter_list:
        if letter in vowels:
    return ''.join(letter_list)