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

guide me about this.Please!

I am not sure for this challenge.I don't understand this.Help me, Guide me Please!

slices.py
def first_4(n):
    item = list(range(n))
    return item[:4]

In this challenge they are wanting you to use the slice() method. So for the first step all you have to do is type your method heading and then the return and then the variable that is passed in (in your case the 'n') and add the brackets "[]" and inside the brackets you need to add the starting point then a colon then your stopping point point then a colon and then the number of steps through the process so it should look like this:

return n[start : stop : step] or in this case:

return n[0 : 4 : 1]

1 Answer

Ok. Thanks a lot.Jeremy Hill

You're welcome