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

Jaime Castillo
Jaime Castillo
5,800 Points

It is glitching, It saids it is wrong. I am on the third one and it saids I am on the second one.

My code: def odds(iter): return iter[1::2]

def first_4(iter):
    return iter[:4]
def first_and_last_4(iter):
    return iter[:4] + iter[4:]

I have had similar problems before with other challenges. If you are 100% sure that nothing is wrong with your code, the try restarting the challenge. Sometimes that works.

1 Answer

Steven Parker
Steven Parker
230,230 Points

This code does not solve the task 2 challenge to create "first_and_last_4". You seem to have the right idea, but the implementation isn't quite right.

Hint: check the slice arguments for "last 4".