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

why i am not getting the desired output

def disemvowel(word): my_list = list(word) print(my_list) for x in my_list: if x.upper() in ["A","E","I","O","U"]: my_list.remove(x) print(my_list) print("".join(my_list)) disemvowel("vsEJaUe")

1 Answer

Steven Parker
Steven Parker
231,236 Points

Here's a few hints:

  • you only need to define the function, you won't need to call it
  • you will not need to print anything
  • the function must return the result
  • removing items in a loop from the loop's iterable can cause other items to be skipped over
  • a slice can be handy to make a copy of a list

Also, when posting code use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.