Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Lists Disemvowel

Jason Smith
Jason Smith
7,439 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,862 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