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 trialAbdulkadir Kollere
1,723 PointsTry again error
The code gives me the try again message. I cant find anything from my end. Anyone for the rescue please?
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
markmneimneh
14,132 PointsHello
you should be using == instead of =
if this answers your question, please mark question as answered.
markmneimneh
14,132 PointsHello
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
1,723 PointsHi! 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.
Abdulkadir Kollere
1,723 PointsAbdulkadir Kollere
1,723 PointsThanks 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.