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

Oszkár Fehér
.a{fill-rule:evenodd;}techdegree seal-36
Oszkár Fehér
Treehouse Project Reviewer

this does what the question ask and still not ok

i am confused a little bit here, somebody can explain please

def first_4(args):
    return args[:4]

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

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

def reverse_evens(args):
    evens = []
    for x in args:
        if x % 2 == 0:
    return evens[::-1]

2 Answers

Christopher Shaw
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Shaw
Python Web Development Techdegree Graduate 58,248 Points

You would expect return args[::-2] to simply work, but this does not take into account if the length of args is odd or even to start with. It is best to first get a list of all the even numbers and then reverse it.

def reverse_evens(args):
    new = args[::2]
    return new[::-1]