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 trial

Python Python Collections (2016, retired 2019) Slices Slice Functions

Task 1 is no longer passing

Hi everyone .... I'm working on Task 2 of this challenge, but I keep getting this error "Task 1 is no longer passing". Here's the question for Task 2: Great work! OK, this second one should be pretty similar to the first. Make a new function named first_and_last_4. It'll accept a single iterable but, this time, it'll return the first four and last four items as a single value. Can someone kindly give me an insight as to why I'm getting this weird error? Thanks so much in advance.

slices.py
def first_4(iterable):
   return first_4[0:4]

def first_and_last_4(iterable2):
    first4 = iterable2[:4]
    last4 = iterable2[-4:]
    return  first4 + last4 

2 Answers

Stuart Wright
Stuart Wright
41,120 Points

As the error message implies, the issue is actually in your first function (you must have had it correct at some point to pass part 1, but it's wrong in the version you've posted above).

Your first function should read:

def first_4(iterable):
    return iterable[0:4]

Your error was in the return statement. Your second function works correctly, and should pass the challenge when you amend the first function.

cool .... thanks for your help, Stuart. I must be really tired, I didn't notice that :-)