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 trialJohn Schut
2,317 PointsFunction first_4
My solution is: def first_4(argument): print(argument[:4])
first_4([1,2,3,4,5,6])
But the response is given that a None is returned in stead of [1,2,3,4].
In a seperate Workspace of mine, the same function returns [1,2,3,4]...(?)
What goes wrong?
def first_4(argument):
print(argument[:4])
first_4([1,2,3,4,5,6])
4 Answers
Carlos Federico Puebla Larregle
21,074 PointsYou are doing it right but the code challenge is asking for you to make a function that returns the first 4 instead of printing them. Do it like this:
def first_4(iterable):
return iterable[:4]
I hope that helps a little bit
John Schut
2,317 PointsHi Carlos, thanks!
Sharon Walls
9,234 PointsReturn vs. print gets me all the time. I've learned to read carefully as a result.
Good luck!
John Schut
2,317 PointsHi Sharon, thanks! Reading is indead a big challenge.... :-)