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 (Retired) Lists Redux Disemvoweled

Julia Gron
Julia Gron
3,170 Points

unsure why my script isn't working, can anyone take a look?

word_list = ["lama", "lama", "lama"] vowels = list('aeiou') output=[]

for word in word_list: for vowel in vowels: while True: try: word_list.remove(vowel) except: break output.append(''.join(word_list))

print(word_list)

3 Answers

Martin Cornejo Saavedra
Martin Cornejo Saavedra
18,132 Points

I did this, I hope this helps:

word = 'lama'
word_list = list(word)
vowels = 'aeiou'

for letter in word_list[:]:
    if letter in vowels:
        word_list.remove(letter)

print(''.join(word_list))

Next time use codetags, it's easier to read your code. Look on 'Markdown Cheatsheet' for more info.

my code is slightly longer way

word_list = ["lama","lama","lama"]

def deVowel(my_word_list):
  new_list=[]
  new_word=""
  for word in my_word_list:
    if "a" in word:
      new_word = word.replace("a","")
    if "e" in word:
      new_word = word.replace("e","")
    if "i" in word:
      new_word = word.replace("i","")
    if "o" in word:
      new_word = word.replace("o","")
    if "u" in word:
      new_word = word.replace("u","") 
    new_list.append(new_word) 
  return new_list  


print("".join(deVowel(word_list)))  
Martin Young
Martin Young
10,329 Points

You're trying to remove vowels from your word list, rather than from each word. I think

      try:
        word_list.remove(vowel)

should actually be

      try:
        word.remove(vowel)

Note that your last line in your block should be

        output.append(''.join(word))

In the video, Kenneth used 'state_list' to be a list of letters in each state name, rather than a list of states. That may be where you're getting confused.