Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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]

slices.py
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
216,057 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".