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 trialtyler bucasas
2,453 Pointsslices.py
im just stuck on step 2 of this challenge. specifically the part when it asks for the last 4 items.
def first_4(list):
return(list[:4])
def first_and_last_4(list):
return(list[:4 and -4::-1])
1 Answer
Steven Parker
231,269 PointsHere's a few hints:
- you can't combine values with logic operators to make one slice do two things
- but you can concatenate separate strings together with the "+" operator
- you might use two different slices for the first and last parts
tyler bucasas
2,453 Pointstyler bucasas
2,453 PointsSteven Parker am I on the right track?
Steven Parker
231,269 PointsSteven Parker
231,269 PointsVery close! But you don't need to reverse the order of the last 4 items.
Also, you don't need to enclose the terms in parentheses (but it doesn't cause a problem in the challenge).