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 trialEmilio Andere
495 PointsI know this is wrong, don't know why! What is missing?
Thank you for every help possible
def first_4():
list1 = ["Emilio", "Soccer", "Love", "Microsoft", "brick"]
list1[:4]
first_4()
2 Answers
Steven Parker
231,236 PointsYour function should take an argument, which will be a list, and return the first 4 items from it. You would put a name (perhaps "list1") between the parentheses on the "def" line.
You won't need to create your own list inside the function. You can remove the 2nd line.
And you also only need to define the function, you don't need to call it.
Manish Giri
16,266 PointsRead the instructions again. Your function is provided with an interable, and you need to return the first four items from it -
def first_4(list1):
return list1[:4]
You're instead creating your own list in the function.
Emilio Andere
495 PointsEmilio Andere
495 Pointswhat do you mean by define the function?
Steven Parker
231,236 PointsSteven Parker
231,236 PointsThe indented code that follows the "def" line defines the function. Putting the function name on a line with parentheses after it invokes (calls) the function, and is not part of the challenge.