Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (2016, retired 2019) Lists Disemvowel

Abdulkadir Kollere
Abdulkadir Kollere
1,723 Points

Try again error

The code gives me the try again message. I cant find anything from my end. Anyone for the rescue please?

disemvowel.py
def disemvowel(word):
    word_list = list(word)
    index = 0
    while (word_list < len(word_list)):
        if word_list[index] = "a" or word_list[index] = "e" or word_list[index] = "i" or word_list[index] = "o" or word_list[index] = "u":
            del word_list[index]
        elif word_list[index] = "A" or word_list[index] = "E" or word_list[index] = "I" or word_list[index] = "O" or word_list[index] = "U":
            del word_list[index]
        index = index + 1   
    return word

2 Answers

Hello

you should be using == instead of =

if this answers your question, please mark question as answered.

Abdulkadir Kollere
Abdulkadir Kollere
1,723 Points

Thanks Mark. I think that is part of the issue. I changed that and the error is now 'try again'. I know the logic is correct, but maybe some syntax I cant figure out.

Hello

Please take a look at this code ... please spend some time comparing to what you did. The ket part to realize is how this p2 lines

for letter in word.lower():
        if letter in vowels: 

can replace a lot of the code writing you were doing:

def disemvowel(word):
    new_word = word
    vowels = ('a', 'e', 'i', 'o', 'u')
    for letter in word.lower():
        if letter in vowels:
            new_word = new_word.replace(letter, "")
    return new_word

print(disemvowel("abcdefghijklmopqrst"))

run the example with different strings using a conole or IDE

thanks

Abdulkadir Kollere
Abdulkadir Kollere
1,723 Points

Hi! I am still stuck in this step. I tried the below code in the workspaces and it was bringing out the right result but in here it gives an error: 'got back the letters I wasn't expecting.

def disemvowel(word): vowels = ['a', 'e', 'i', 'o', 'u'] new = list(word.lower()) for letter in new: if letter in vowels: word = new.remove(letter) return word

Any assistance will be appreciated.