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 trialMladen Rajkovic-Alvik
7,279 PointsMake a function name first_and_last_4 that accepts an iterable and returns the first 4 and last 4 items in the iterable?
Don't know how to solve this one? Cab somebody please give me a hint?
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThere are four parts to this task:
- define function named
first_and_last_4
that accepts an iterable - get first 4 item (a slice would work nicely)
- get last 4 items (again a slice)
- return both slices
def first_and_last_4(iter1):
first4 = ???
last4 = ???
return first4 + last4
Can you define the two needed slices?
Post back if you need more help