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

Jason Smith
Jason Smith
8,668 Points

can anyone see the syntax error i made?

i can't find it for the life of me! it says it's on line 6, but i don't see a problem there.

disemvowel.py
def disemvowel(word):
    word = [word]
    for vowel in word:
        while vowel == 'a' or 'e' or 'i' or 'o' or 'u' or 'A' or 'E' or 'I' or 'O' or 'U':
            word.remove(vowel)
            except ValueError:
                break
    return (word)

1 Answer

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Jason,

The particular error that you are running into on line 6 is that you are using an except without a corresponding try.

You do have a couple of other issues with your code:

  • you need to return a string but you are returning a list;
  • you're using a while loop on vowel but you only look at that character once, so you would be better to use an if
  • you're using a for loop to iterate through the same iterable that you are removing items from.

Hope that points you in the right direction

Cheers

Alex