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

qifeng sun
qifeng sun
6,274 Points

it keep telling me to try again, not really sure whats wrong

You're on fire! Last one and it is, of course, the hardest. Make a function named reverse_evens that accepts a single iterable as an argument. Return every item in the iterable with an even index...in reverse. For example, with [1, 2, 3, 4, 5] as the input, the function would return [5, 3, 1]. You can do it!

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

def first_and_last_4(iterable_thing2):
    first= iterable_thing2[:4]
    last = iterable_thing2[-4:]

    return first+last

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

def reverse _evens(item):
    even_items = item[0::2]
    reverse_items = even_items[-1::-1]
    return reverse_items

1 Answer

Stuart Wright
Stuart Wright
41,120 Points

All of your logic is correct. You just have a space after the underscore in your function name. Fix that and your code will pass:

def reverse _evens(item):