Python Python Collections Slices Slice Functions

Jalen Wize
PRO
Jalen Wize
Pro Student 2,505 Points

First 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!

slices.py
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
Cheo R
Cheo R
35,541 Points

I 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.

Jalen Wize
Jalen Wize
Pro Student 2,505 Points

Okay cool that is the way I'm doing it above. Do you see anything in my code I'm missing?

KRIS NIKOLAISEN
KRIS NIKOLAISEN
Pro Student 42,407 Points

You have a typo in spelling list here

last_4 = copy_item_lsit[-4:]
Jalen Wize
Jalen Wize
Pro Student 2,505 Points

Thank 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
Cheo R
35,541 Points

One 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.