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!
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
Itai Shin9,928 Points
ODD index literable
In the course "Python Collections" there is a question about Slices.
Create a new function named odds that returns every item with an odd index in a provided iterable. For example, it would return the items at index 1, 3, and so on. Write a function that returns new literable, with only the odd indexes.
Here is my answer
def odds(iterable): reverse_list = iterable[::-2] return new_list[::-1]
The website says that its wrong. Is there anybody that knows what is wrong with my answer?
Chris FreemanTreehouse Moderator 68,332 Points
You’re thinking in the correct direction. First, the function name should be
new_list should be
Your code reverses the evens from the back of the list. Then it reverses this again.
Instead, get the evens in regular order, then reverse that result.
Post back if you need more help. Good luck!!!