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

slices.py Task 4/4 - This seems to run fine in IDLE?

This code seems to run fine in IDLE, but for some reason is coming up bad when I do it in the coding challenge. Am I missing something? reverse_evens(iterable)

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

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

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

def reverse_evens(iterable):
    if len(iterable) % 2 == 0:
        return iterable[-2::-2]
    else:
        return iterable[-1::-2]

3 Answers

Your code worked perfectly for all four tasks for me, try restarting your browser and running again.

yeah, it's working now. that's a relief! thanks for your responses.

Ryan Bailey
Ryan Bailey
824 Points

Is there a reason this didn't work for challenge 4/4?

def reverse_evens(items):
    return items[::-2]
Steven Parker
Steven Parker
231,275 Points

The sample above might give you a clue. If you need more help, please start a fresh question of your own.