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 (Retired) Slices Slice Functions

Christopher Lobato
Christopher Lobato
1,625 Points

Am I missing something?

Says the last number of the iterable is 48 instead of 49 when i do [-1]???

def first_4(ite):
    return ite[0:4]

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

def first_and_last_4(ite):
    return ite[0:4] + ite[-4:-1]

1 Answer

Steven Parker
Steven Parker
231,275 Points

:point_right: Remember what happens if you leave off one of the values in a slice.

If you leave off the first value, it defaults to the first item. If you leave off the second value, it defaults to the last item.