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

Is anything wrong with reverse_evens ?

Is there any wrong with reverse_evens function

slices.py
def first_4(shopping_list):
    return shopping_list[:4]

def first_and_last_4(p_list):
    return p_list[:4] + p_list[-4:]

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

def reverse_evens(r_list):
    return r_list[::-2]

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

if it is supposed to return the even indices in reverse order, yes. it begins at the last element in the list, so if that list has an even number of elements, due to the zero-indexed nature of python lists, the last element will have an odd index. then as you move to the beginning of the list by twos, the returned elements will be the negative indices. find an adjustment that only returns the even indices.