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

Greg Maddox
Greg Maddox
1,471 Points

I just cant get this one!

I don't understand how this negative even slicing works. It seems like it should, but it keeps starting at the second element, not the [0]

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

def first_and_last_4(array):
    second_list = array[:4]
    return second_list

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

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

4 Answers

Steven Parker
Steven Parker
229,788 Points

There's a bit more to the last task. Consider that to return only the even indexed values, you would need to start at either the last or the second-to-last item depending on whether the list had an odd or even number of items in it.

So you'll either need to compute the starting position based on list size, or extract the even indexes first and then reverse them.

Greg Maddox
Greg Maddox
1,471 Points

Thanks a lot! That was very helpfully, i was able to finish the challenge.

this worked for me...

def sillycase(i):
    half = int(round(len(i)/2))
    low = i[:half].lower()
    upp = i[half:].upper()
    return (low + upp)
Steven Parker
Steven Parker
229,788 Points

I believe that's for a different challenge! :wink:

you're right ;-) ....I had maybe too much screens, silly me