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 trialJalen Wize
Courses Plus Student 2,559 PointsFirst 4 and last 4 values of an iterable, what output am I looking for?
I may be missing what output the question is looking for. I also tried ' '.join(a) to put first 4 and last four as one value. Thanks!
def first_4(item):
item_list = list(item)
copy_item_list = item_list[:]
return copy_item_list[:4]
def first_and_last_4(item):
item_list = list(item)
copy_item_list = item_list[:]
first_4 = copy_item_list[:4]
last_4 = copy_item_lsit[-4:]
a = first_4.extend(last_4)
return a
Jalen Wize
Courses Plus Student 2,559 PointsOkay cool that is the way I'm doing it above. Do you see anything in my code I'm missing?
Jalen Wize
Courses Plus Student 2,559 PointsThank you... always the little things. I also discovered in going through the forums that I was over complicating this. Thanks for the help!
Cheo R
37,150 PointsOne thing that has helped with code challenges is to try to make test to run with my code. Sometimes it'd take some time to figure out what they're testing for but I think in the end it's worth it.
1 Answer
KRIS NIKOLAISEN
54,971 PointsYou have a typo in spelling list here
last_4 = copy_item_lsit[-4:]
Cheo R
37,150 PointsCheo R
37,150 PointsI got first_and_last_4 to pass by returning a list made of the first 4 and last 4.
Did not use join to return them as a string.