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.


Blair Owens
Blair Owens
8,235 Points

Is there an error with Treehouse or am I getting something wrong? Make a function named odds that accepts an iterable

I'm having trouble with this question. It say's it expected "kaoa", I'm not sure where that combination of letters came from and even when I change my code to make that the output, I get another error saying. "Where's odds()?"

Make a function named odds that accepts an iterable as an argument and returns the items with an odd index in the iterable.

Bummer! odds() didn't return the right output. Got [1,3,5], expected kaoa

def odds(list2):
  list2 = [0,1,2,3,4,5]
  odds = list2[1::2]
  return odds

1 Answer

Delete the line that says:

list2 = [0,1,2,3,4,5]

This line is redefining the list. You want the list that is passed in as a parameter to be the list that has its odd values returned.

def odds(list2):
  return list2[1::2]