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) Slices Slice Functions

odds

def odds(arg): return arg[::2] This should return odd indexes, but the answer is not correct

2 Answers

Jeffery Austin
Jeffery Austin
8,128 Points

Found this on stackoverflow(http://stackoverflow.com/questions/12433695/extract-elements-of-list-at-odd-positions), this code seems to satisfy the challenge:

def odds(arg):
  return arg[1::2]
Darryn Smith
Darryn Smith
32,043 Points

In my opinion the challenge question isn't clear. I didn't interpret "returns the items with an odd index" to actually mean 'returns only the original list items whose indexes are odd'.

I understand now what he means, but it just wasn't clear the first 27 times I read it.

You can't put too much water in a nuclear reactor.