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 trialMichael Gallego
1,568 PointsNot sure why this is wrong. I made the function that returns first 4 and last 4 from the iterable argument from function
I tested it out in the python shell and it worked perfectly. Not sure why it isn't working here. It's not like i'm assigning a variable. I am just returning first four and last four like it said.
def first_4(whatever):
return whatever[0:4]
def first_and_last_4(imagine):
return imagine[0:4] + imagine[-1:-5:-1]
1 Answer
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsHey Michael Gallego
So the challenge asks you to give you the first 4 and the last 4.
Your code is giving the first 4 and then giving the last 4, but the last 4 is in reverse order. It didn't ask for the last 4 to be in reverse.
Hope that helps! :)
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsExample: If I passed in
I should expect to get back from first_and_last_4 function.
`>>> [1, 2, 3, 4, 7, 8, 9, 10]`