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

Bummer! Didn't get the right values from `reverse_evens`.

I tried different version also but its still not working for me maybe my code is not correct but in my local machine its printing exactly same as it is asking in question but don't know why is it still keep saying Bummer! Didn't get the right values from reverse_evens.

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

def first_and_last_4(y):
    return first_4(y) + y[-4:]

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

def reverse_evens(z):
    a = z[::-1]
    return a[::2]


num = list(range(1,6))

print(reverse_evens(num))

2 Answers

Todd Anderson
Todd Anderson
4,260 Points

I'm not exactly sure why, but you need to have the variable a = z[::2] and then return it in reverse like return a[::-1]

both work the same in the shell, but the challenge requires it the way I have described.

Thanks it works :)