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.

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.

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))


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 :)