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

Please help i dont know what to do

Can someone please help me figure out what's wrong?

slices.py
def first_4(1, 2, 3, 4):
    return first_4[:4]

2 Answers

It seems that you still aren't exactly familiar with defining functions. When defining a function, you should have the parameters in the parentheses, not the arguments themselves (the purpose of a function is to provide it different arguments at different times). Try:

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

Oooh, Thanks i was just a bit mixed up with what it was asking me. Thanks for the help!

No problem :)

Hi Anthony, the method's parameter should be a variable that is iterable. I just call it iterable or whatever works for you. Your slice specification is absolutely correct, but you should slice the parameter (iterable) that you provide to the method.

Look at this:

# iterable is the parameter that the first_4 function expects
def first_4(iterable):
    # slice the parameter and return it
    return iterable[:4]

Does it make sense?

Ya i get it now. Thanks a lot for the help!

You are very welcome, Anthony.