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 trialsarvienn thevendran
734 Pointsfirst and last 4 function
i've tried this on a normal code editor it seems to work but the treehouse editor doesnt accept this as an answer. anyone?
def first_4(it):
it = it[:4]
return it
def first_and_last_4(it):
return str(it[:4]) + str(it[-4:])
1 Answer
John Lack-Wilson
8,181 PointsHi Sarvienn, it's because you're returning them as a string value. Whereas the function should be able to return it as a list or a string or anything other type of iterable it passes to it.
So the return statement on your first_and_last_4 function should be:
return it[:4] + it[-4:]