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

reverse_evens def reverse_evens(*num): return num[::-2]

it runs without any error in jupyter ,i do not understand the problem

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

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

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

def reverse_evens(num):
    return num[::-2]

2 Answers

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Sounds like you didn't handle enough test cases in jupyter.

Your code correctly returns [5, 3, 1] for a list with an odd number of items [1, 2, 3, 4, 5].

If you try testing a list with an even numbers like [1, 2, 3, 4, 5, 6] you'll get back the incorrect [6, 4, 2] because you are starting at the end and stepping -2. So you get back the odd ones.

You need to specify the correct starting point (the challenging part) - just ask if you need additional guidance.