Python Python Collections 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:]
Zara Thomas
Zara Thomas
7,522 Points

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
163,023 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".